PDA

View Full Version : Pausing AS in AS...



blah-de-blah
August 26th, 2003, 12:52 AM
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!

kO2n
August 26th, 2003, 02:34 AM
Hi,

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.

Regards,
Viru.

blah-de-blah
August 26th, 2003, 06:09 AM
Thanks, but what if i don't have another function to call? And if what i'm exiting is not a method?? :-\

kO2n
August 26th, 2003, 08:29 AM
Then i cant help, sorry. I dont know how or what to do.

Regards,
Viru.

pom
August 26th, 2003, 10:07 AM
Use setInterval :)


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 :)

blah-de-blah
August 26th, 2003, 10:13 AM
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!

blah-de-blah
August 26th, 2003, 10:19 AM
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?! :P

pom
August 26th, 2003, 10:33 AM
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 :)