?
Solved

Flash CS3 Timer routine

Posted on 2008-11-04
3
Medium Priority
?
311 Views
Last Modified: 2013-11-11
I am working in Actionscript 3.0

I have two functions

startSomthing();

endSomething();

I also have an array

"one","two","three"


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.

thanks


0
Comment
Question by:lexshine
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Spy6
ID: 22884349
Hi!

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.

0
 

Author Comment

by:lexshine
ID: 22884407
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); 
            wholeTimer.start(); 
			
			
			function onWholeComplete(event:TimerEvent):void{
			CircleRemove();
 
 
			}
 
       CircleFocus();
 
}

Open in new window

0
 
LVL 4

Accepted Solution

by:
Spy6 earned 2000 total points
ID: 22884468
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); 
            wholeTimer.start();
            CircleFocus(myArray[crtItem]);
 
}
 
                        function onWholeComplete(event:TimerEvent):void{
                            CircleRemove(myArray[crtItem]);
                            crtItem++;
                            wholeTimer.stop();
                            if (crtItem < myArray.length)                                                                         
                                   showPlay();
                         }

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question