Solved

Acrionscript 3.0 how to pause a for loop

Posted on 2008-10-05
2
974 Views
Last Modified: 2013-11-11
I see the "almost" answer I need in a thread for AS2.0:
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_23359115.html#a21462740

How would you do this for AS3.0 using the Timer?

So, my question is how do you get the timer to pause the for loop so the dynamic mcs can appear one at a time after a predetemined pause.

Thanks for your help.



BTW: Here is a copy of the answer for AS2 given in the above post:
 
//forget the for loop! Use only the timed functions:
 
var delay = 1000; // 1 second
var count = 0;
var timerId = setInterval(createMC,delay, this);
function createMC(obj){
         trace("function");
        var thumb:MovieClip = obj.attachMovie("thumb", "thumb"+i, i, {_x:xPos, _y:yPos});
                  thumb.gotoAndPlay(2);
                  obj.count++;
                  if(count >= _global.projThumb.length){
                           clearInterval(obj.timerID);
                   }
        }

Open in new window

0
Comment
Question by:gtaffet08
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
asaivan earned 500 total points
ID: 22646118
Well, in AS3, you just tell the timer to wait...If I understand your needs correctly.  Here's a good tutorial on the Timer class
http://blogs.adobe.com/pdehaan/2006/07/using_the_timer_class_in_actio.html

and the code below illustrates the Timer class in relation to what you might need
var delay:uint = 1000; //delay is measured in milliseconds;
var numLoops:uint = projThumb.length; //numLoops would be some number of times you want the loop to run
var timr:Timer = new Timer( delay, numLoops );
 
timr.addEventListener(TimerEvent.TIMER, createMC);
timr.start();
 
private function createMC( event:TimerEvent ):void
{
   //create the MCs or whatever here
}

Open in new window

0
 

Author Closing Comment

by:gtaffet08
ID: 31503235
Thank you. Your answer helped me to see what I was doing wrong and helped me to get my code to work. I didn't understand that I needed to use the timer to actually create the mcs. I was trying to use the timer in conjunction with a for loop. Thanks again for your quick answer!
0

Featured Post

Independent Software Vendors: 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.

726 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