# How to pause this script mid-execution?

**URL:** <https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179>\
**Category:** flash\
**Created:** [May 23, 2008, 9:55pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179 "2008-05-23T21:55:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdoodle](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@mrdoodle](https://forum.kirupa.com/u/mrdoodle)\
**Post date:** [May 23, 2008, 9:55pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/1 "2008-05-23T21:55:24Z")

</div>

Hi there forum folk,

This is my first ever post, so please excuse any posting protocol errors. One lives and learns.

Anyway I have this script below that is attached to a button called Espanol\_but that when the button is clicked(released) moves itself and several other buttons and movie clips around the stage using the tweenClass.

on (release) {  
import mx.transitions._;  
import mx.transitions.easing._;

// Espanol\_nut jumps to the ground  
twnBezX = new BezierTween(EspanolNut, “\_x”, 119.5, 0, 7, false, 120, 70);  
twnBezY = new BezierTween(EspanolNut, “\_y”, 135.2, 460, 7, false, -50, 200);  
twnBezX.\_tl = this;  
twnBezX.onMotionFinished = function(){  
this.\_tl.tweenDone();  
}

_ **PAUSE** _

//Language buttons bounce off stage to the left  
var xPosT:Tween = new Tween(Espanol\_but, “\_x”, Elastic.easeInOut, 117.1, -500, 2.7, true);  
var xScaleT:Tween = new Tween(Espanol\_but, “\_rotation”, Elastic.easeInOut, 0, 360, 4, true);

```
var xPosT:Tween = new Tween(Francais_but, "_x", Elastic.easeInOut, 322.1, -500, 1.7, true);
var xScaleT:Tween = new Tween(Francais_but, "_rotation", Elastic.easeInOut, 0, 360, 2.5, true);

var xPosT:Tween = new Tween(Deutsch_but, "_x", Elastic.easeInOut, 527.5, -500, 3.2, true);
var xScaleT:Tween = new Tween(Deutsch_but, "_rotation", Elastic.easeInOut, 0, 360, 4.5, true);

```

_ **PAUSE** _

//Francais & Deutsch nuts bounce off stage to the left  
var xPosT:Tween = new Tween(FrancaisNut, “\_x”, Elastic.easeInOut, 324.4, -500, 1.7, true);  
var xScaleT:Tween = new Tween(FrancaisNut, “\_rotation”, Elastic.easeInOut, 0, 360, 2.5, true);

```
var xPosT:Tween = new Tween(DeutschNut, "_x", Elastic.easeInOut, 529.9, -500, 2.7, true);
var xScaleT:Tween = new Tween(DeutschNut, "_rotation", Elastic.easeInOut, 0, 360, 4, true);

```

_ **PAUSE** _

//Year buttons bounce on from right of stage  
var xScaleT:Tween = new Tween(Year4, “\_rotation”, Elastic.easeInOut, 90, 0, 3.5, true);  
var xPosT:Tween = new Tween(Year4, “\_x”, Elastic.easeInOut, 1200, 416.9, 3.5, true);

```
var xScaleT:Tween = new Tween(Year3, "_rotation", Elastic.easeInOut, 90, 0, 2.5, true);
var xPosT:Tween = new Tween(Year3, "_x", Elastic.easeInOut, 1200, 167.4, 2.5, true);

var xScaleT:Tween = new Tween(Year6, "_rotation", Elastic.easeInOut, 90, 0, 3.9, true);
var xPosT:Tween = new Tween(Year6, "_x", Elastic.easeInOut, 1200, 416.9, 4, true);

var xScaleT:Tween = new Tween(Year5, "_rotation", Elastic.easeInOut, 90, 0, 2.9, true);
var xPosT:Tween = new Tween(Year5, "_x", Elastic.easeInOut, 1200, 167.4, 3, true);

```

}

Right…What I want to do is pause the executiuon of the code for about 2 seconds at each point that i’ve marked the code above with the word _ **PAUSE** _.  
That way there is a slight lag between each of the buttons and movie clips animating around the stage.

Please can someone help me wih the code I need to make this happen, as I don’t really understand AS too well and need to get this working.

Thanks so much in advance if you can help me with the code I need.

mrdoodle 👁

---

<div class="post-metadata">

**Author:** ![Loyx](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@Loyx](https://forum.kirupa.com/u/Loyx)\
**Post date:** [May 24, 2008, 10:00am UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/2 "2008-05-24T10:00:14Z")

</div>

Well, you can follow this:

> **[\[Flash8\]Help needed! in pausing script. Look at this thread please!](https://www.kirupa.com/forum/showthread.php?t=298842)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

---

<div class="post-metadata">

**Author:** ![stupidsaint](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@stupidsaint](https://forum.kirupa.com/u/stupidsaint)\
**Post date:** [May 24, 2008, 5:43pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/3 "2008-05-24T17:43:25Z")

</div>

well first things first, put the

```auto
 import mx.transitions.*;
import mx.transitions.easing.*;

```

code on a keyframe or it will only load them in when you press witch will slow things down.

second, the only way i see you being able to do this is to make a counter…

```auto

```

\_global.counter += 1

```auto

```

then do some if tests like

```auto

if(_global.counter >= 60){
//start the next tween
tweenName.start();
}

```

the number 60 would work if your FPS was 30… 30\*2 = 60 (2 seconds)

hope this helps,  
Stupid Saint

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [May 26, 2008, 7:33am UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/4 "2008-05-26T07:33:49Z")

</div>

do you want the animation to happen in a sequence and not simultaneously. is that what you want. is that why you want a lag ? so that there is a sight delay between the animation of two items ?

---

<div class="post-metadata">

**Author:** ![mrdoodle](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@mrdoodle](https://forum.kirupa.com/u/mrdoodle)\
**Post date:** [May 27, 2008, 8:21am UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/5 "2008-05-27T08:21:00Z")

</div>

Hi thanks for your replys guys, been away so haven’t been able to respond.

In answer to your question sparkdemon, Yeah I want the animation to be staggered, not all happening at once. So I need some way of creating a deley after each tween befor the next one happens.

I don’t understand AS very well at all, so I’m grateful for the code you suggested, but don’t know how to implement it.

```auto

_global.counter += 1

if(_global.counter >= 60){
//start the next tween
tweenName.start();
}

```

Do I just stick this in my script as is. I imagine I have to put something in where you wrote:

```auto

tweenName.start();

```

but I don’t know what?

A few more pointers would be most helpful.

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![mrdoodle](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@mrdoodle](https://forum.kirupa.com/u/mrdoodle)\
**Post date:** [May 27, 2008, 10:42am UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/6 "2008-05-27T10:42:27Z")

</div>

[quote=WhiteRau;2331589]well… there’s always good old “.onMotionFinished()”.

WR![/quote]

Thanks, but did you even ead my last post!

Sorry to be blunt, but I am getting sick of people just throwing me a piece of code expecting me to know exactly how to implement it etc, when I have plainly stated that my actionscript knowledge is VERY basic.

What would be useful to me is a working example of some code that I could just drop into my script with information about which parts to change.

I really do appreciate everyones posts, but you must understand how frustrating it is for me, when I get all these replys that I can’t use.

Thanks

Mike

---

<div class="post-metadata">

**Author:** ![Noahdecoco](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Noahdecoco](https://forum.kirupa.com/u/Noahdecoco)\
**Post date:** [May 27, 2008, 12:03pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/7 "2008-05-27T12:03:34Z")

</div>

Ok ok, chill down Mike… firstly, welcome to Kirupa! Your gonna find loads of people here who give you crap information which dont help at all so you better get used to it… but if you dont keep your cool, the ones who wanna help wont wanna help anymore… got it? So relax, and while going through all the rubish replies, search online for help…

Ok, firstly… look up what “.onMotionFinished” is… what it does is, it detects when a tween is over and then does the next animation… so an example would be like this…

Its best you group your transitions into a function first…

firstfunction.onMotionFinished = function():Void{  
secondfunction();  
}

hope this helps…

Take a chill pill… relax… its just code…  
:party:

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [May 27, 2008, 1:01pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/8 "2008-05-27T13:01:46Z")

</div>

ok. well pretty much. if you use google, or F1 help you should find it. Do not expect answers with your rudeness. You need to show that you are willing to learn, figure things out yourself… instead of copying and pasting code and changing a few numbers. Because when it comes to doing it again - with a few changes, you will be asking all the same questions over due to a lack of understanding.

---

<div class="post-metadata">

**Author:** ![Noahdecoco](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Noahdecoco](https://forum.kirupa.com/u/Noahdecoco)\
**Post date:** [May 27, 2008, 2:33pm UTC](https://forum.kirupa.com/t/how-to-pause-this-script-mid-execution/261179/9 "2008-05-27T14:33:28Z")

</div>

If it weren’t for people’s posts who just pointed me in the general direction and thats all, I wouldn’t have learnt so much about flash… gotta get your hands dirty mike…
