A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11260 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Willyam Bradbetrry
» Title: japanese lily
» Description: pseudo 3d art design japanese space
» More by Willyam Bradbetrry


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6326 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Empix Multimedia
» Comments: Empix Multimedia


Random Links | Add your own Flash Related Links
Flash Tutorials 1212 Tutorials 7 New Tutorials Added!
What's New | Top100

» How to Make 3D Wall Flash Photo Gallery
» How to Make Personalized Multimedia Flash eCard in PowerPoint
» How to Create Grown up Christmas List Photo Story
» How to convert Youtube video(online SWF file) to video for portable devices?
» How to Make Flash Christmas Quizzes with Sounds & Videos
» FLV to PSP - How to convert YouTube video to PSP for mac
» Creating widgets fast and easily with SPAS 3.0
» How to Let PowerPoint Memorize like Man
» How to insert YouTube video (Flash video) into PowerPoint
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Contract Web Developers Needed
Aquent
US-PA-Philadelphia

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories New methods: SetInterval, ClearInterval, clear (part2)
Author: Bart Portier | Website: www.azlan.be |

 
Page 1
1 2 3 next»

New MX functions: part 2

setInterval, clearInterval, clear method

Hi 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)
- how can I change the appearance of what I was drawing? (can I use setProperty?)
- how can I time my drawing the way I would in a Movie Tween? (i.e. pausing the drawing for a while)

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() {
_root.createEmptyMovieClip( "triangle"+i , i);
with ( _root["triangle"+i]);
{
lineStyle( 5, 0xff00ff, 100 );
moveTo(i, 10 );
lineTo( i,300 );
//lineTo( 100, 300 );
//lineTo( 200, 200 );
i = i + 10;
trace ("has been called" + i);
j = i/10;
}
}

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) {
i=10;
var quitID;
quitID=setInterval(drawMe, 1000);
trace (quitID);
}

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) {
i=10;
setInterval(drawMe, 1000);
trace (quitID);
}

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) {
clearInterval( quitID );
}

Now I can stop and start things and simulated motion, I want to erase what I have been drawing.

1 2 3 next»

» Level Intermediate

Added: : 2002-04-09
Rating: 5.91 Votes: 11
Hits: 1562
» Author
MCT and Macromedia Trainer and designer
» Download
Download the files used in this tutorial.
Download (69 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers