">'); win.document.writeln(''); win.document.writeln(''); }

The Indefinite Article.

Friday, December 30, 2005

using setInterval()

I've been trying to wrap my head around setInterval() for the past couple of days. I was examing a little piece of java script that Pablo wrote for todd's BigSeason site. (To see what i'm talking about click the big season link and then view the page source. There is a bit of javascript in the head tag that loops through a series of quotations.) Looking at the source, i figured that i had to use setInterval() with a loop to get it to cycle through a function a certain number of times. I could get simple things to dwork:

function doThis(words:String) {
setInterval(doThis,1000,"trace this!");

But i wanted to control a whole series of functions: load a series of movieclips from the library, put them in a particular place, slide em in, slide em out on click... all sorts of stuff. I struggled with it in between phone calls at work and at todd's new place with a Dr. Pepper. Finally, today, while i was gnawing on a piece of Kentucky Fried Chicken at my mom's(which i hadn't had in forever!) it hit me: setInterval() IS the loop. duh!

so i finally got three balls (draggable) to tween onto the stage. See the .fla file with the code here.

Paul & Adolph: could i get a coding critique?


Post a Comment

<< Home