How to pause this script mid-execution?

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

Well, you can follow this:

well first things first, put the

 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…



_global.counter += 1


then do some if tests like


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

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 ?

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.


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


tweenName.start();

but I don’t know what?

A few more pointers would be most helpful.

Thanks,

Mike

[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

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:

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.

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…