Search Tutorials
New MX functions: part 2setInterval, clearInterval, clear methodHi everyone, I hope you liked the first part of this tutorial. Remember? The one where we used the Drawing Object to create a triangle with script. It's fun being able to draw something, but now we want to know what we can do with our drawing: - how can I talk to the instances that we just create them? (what 's the path
I can use) PS... I would make a small tribute to all designers and develloppers who made timer functions, they already wrote ways to use dynamic drawing and timer-functions, which were very inventive. We are the guys who are spoilt now, because Macromedia made specific functions for us. Thanks Macromedia, and thanks to the other guys who made things Macromedia wouldn't even have considered :-) part A: setInterval and clearInterval.Movie Setup: I'm not drawing triangles in these examples. I'm just drawing a line, to keep things as straightforward as possible for everyone. This is the effect I want to achieve: and this is the script I used The script In frame 1 of the first timeline I put this function: function drawMe() {
this function creates a MovieClip, defines the line, and draws it (very much the same as in our first tutorial). I commented out what we used in the first tutorial. I also added some trace information to show you what is happening. This is the code behind the start button: on (release) {
the most important line here is the setInterval. It starts the drawMe function and executes it every 1000 miliseconds. You could leave out the variable quitID if you wanted and just write it like this: on (release) {
it would work just as well, only I want to stop it too. That's why I need some feedback from the function (ie. quitID, so I can stop it using the clearInterval method. Indicating the quitID he knows what functions should be stopped. This is the code behind the start button: on (release) {
Now I can stop and start things and simulated motion, I want to erase what I have been drawing.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|