Flash CS3 Timer routine

I am working in Actionscript 3.0

I have two functions



I also have an array


I need a routine that will move through the array and execute the following functions

startSomthing(); for a set amount of time, say 1 minute

endSomething(); execute the end routine after 1 minute

then repeat until all elements of the array have been passed through, so based on the array above it would last for 3 times.

I have tried some things in Actionscript but havent been able to figure out the routine to make this happen.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


As I understand you want to call startSomething and then have another function that after 1 minute will stop the execution of startSomething. This is just not possible because Flash is single-threaded so as long as startSomething is running you cannot call another function. Also you can't just stop a function from executing.

lexshineAuthor Commented:
Well, Here is what I have going on now. I call showPlay() which calls the function CircleFocus which starts the action.

I then have a timer that shuts down the CircleFocus routine called CircleRemove.

That is the equivilent of startSomthing and endSmthing running.

What I need to know is how to move through the array and call showPlay(), then recognize when its done and go to the second element in the array and call showPlay() again, etc.

public function showPlay(){
            var wholeTimer:Timer = new Timer(1000, 15); 
            wholeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onWholeComplete); 
			function onWholeComplete(event:TimerEvent):void{

Open in new window

This should do the trick.
public var crtItem = 0;
public var myArray = ["one", "two", "three"];
public function showPlay(){
            var wholeTimer:Timer = new Timer(1000); 
            wholeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onWholeComplete); 
                        function onWholeComplete(event:TimerEvent):void{
                            if (crtItem < myArray.length)                                                                         

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.