Pausing AS in AS

Does anyone know how you can pause an actionscript code? I’ve found posts which explain how to pause animations, but none on how to pause actual actionscript commands :-\

A quick example would be to make a box increase in size (which was done through AS). But when it gets to 100 pixels wide, i want it to pause for 3 seconds before continuing again. Thanks for the help!


You can use the break; command to exit a method. And then at the same time you exit the code you can call an interval that has been made to call another function after 3 seconds, then clear that interval.


Thanks, but what if i don’t have another function to call? And if what i’m exiting is not a method?? :-\

Then i cant help, sorry. I dont know how or what to do.


Use setInterval :slight_smile:

blabla.onEnterFrame = function() {
 // do stuff
if (this._xscale > 100) {
delete this.onEnterFrame ;
this.interval = setInterval (this, "grow", 3000) ;

where grow could be a nice little prototype that makes a clip grow.

pom :slight_smile:

Doesn’t setInterval keep repeating? anyways this is the code i have:

function lengthIn(mc1, finWidth, finHeight) {
mc1.onEnterFrame = function() {
mc1._width += 30;
if (mc1._width>=finWidth) {
mc1._width = finWidth;
//Trying to get the 3 seconds to start here, and then do the stuff under
mc1._height += 30;
if (mc1._height>=finHeight) {
mc1._height = finHeight;
delete mc1.onEnterFrame;

This is what i’m tryin to do (if you look at the comment in the code that is what i want…but i’m not sure how i can do it :-\ thanks!

Then again, if i changed the bottom bits to function it should work…then i’d need lots of extra functions though so is there another way?! :stuck_out_tongue:

*Originally posted by blah-de-blah *
**Doesn’t setInterval keep repeating? **
All you have to do is clear the interval in the grow function.

Check Sen’s site, he has a good explanation of all this :slight_smile: