Flash CS3 Timer routine

Posted on 2008-11-04
Last Modified: 2013-11-11
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.


Question by:lexshine
    LVL 4

    Expert Comment


    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.


    Author Comment

    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

    LVL 4

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    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…
    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now