Really need help in pausing this button 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:

The best way would be to create a function for each of the tween events, e.g.
function espanolFn() {
// 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();
}
}
Do the same for function languageFn(), function frenchFn() and function yearFn()

At the end of each function include the following code:
clearInterval(pause);

Then add the following as the last line of the espanolFn:
pause = setInterval(languageFn, 2000);

this to the end of the languageFn:
pause = setInterval(frenchFn, 2000);

and this to the end of the frenchFn:
pause = setInterval(yearsFn, 2000);

Finally, place this single line into your button’s onRelease handler:
pause = setInterval(espanolFn, 2000);

[quote=glosrfc;2330362]The best way would be to create a function for each of the tween events, e.g.
function espanolFn() {
// 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();
}
}
Do the same for function languageFn(), function frenchFn() and function yearFn()

At the end of each function include the following code:
clearInterval(pause);

Then add the following as the last line of the espanolFn:
pause = setInterval(languageFn, 2000);

this to the end of the languageFn:
pause = setInterval(frenchFn, 2000);

and this to the end of the frenchFn:
pause = setInterval(yearsFn, 2000);

Finally, place this single line into your button’s onRelease handler:
pause = setInterval(espanolFn, 2000);[/quote]

Hi glosrfc,

Thanks for the relpy. I am truly grateul to everyone who is helping me out here, unfortunately my actionscript skills are very minimal, and the code that you presented me with just goes straight over my head. I tried just pasting it instead of the code I had before, but it doesn’t work and I do not understand why.

It would be really helpful if you could advise me further on how to create these functions. And if at all possible give me the actual code I would need and obviously point out any other bits I need to add, that you yourself might just take for granted as being known.

Thanks

Mike

It’s fairly self-explanatory. Take each of the sections from your code (those bits between the PAUSES) and turn them all into separate functions using the espanolFN example I’ve already given. It’s simply a matter of creating a function like so:
function name() {
}

and then pasting the code you’ve already got between the brackets. Once you’ve created these functions you then need the code to call them. Ordinarily you would call them with the function name, e.g.
espanolFn(); or languageFn();

but, in this case, you need to create a pause. You do this using setInterval which calls a function after a period (expressed in milliseconds) has passed. That’s what the remaining code does. First, each function contains the code to clear the interval so that you can be sure it’s not still running. Then each function in turn calls the next function using setInterval with a delay of 2000 milliseconds.

Obviously you can’t simply copy and paste everything I’ve provided as most of it won’t be understood because they’re instructions to you, and not instructions to the Flash Player. But equally, I’m not going to code the entire thing for you because a) most of it is already there and simply needs tweaking as per my instructions to you and b) it will ultimately help you to understand how to create repetitive code by using functions if you were to do it yourself.

[quote=glosrfc;2331951]It’s fairly self-explanatory. Take each of the sections from your code (those bits between the PAUSES) and turn them all into separate functions using the espanolFN example I’ve already given. It’s simply a matter of creating a function like so:
function name() {
}

and then pasting the code you’ve already got between the brackets. Once you’ve created these functions you then need the code to call them. Ordinarily you would call them with the function name, e.g.
espanolFn(); or languageFn();

but, in this case, you need to create a pause. You do this using setInterval which calls a function after a period (expressed in milliseconds) has passed. That’s what the remaining code does. First, each function contains the code to clear the interval so that you can be sure it’s not still running. Then each function in turn calls the next function using setInterval with a delay of 2000 milliseconds.

Obviously you can’t simply copy and paste everything I’ve provided as most of it won’t be understood because they’re instructions to you, and not instructions to the Flash Player. But equally, I’m not going to code the entire thing for you because a) most of it is already there and simply needs tweaking as per my instructions to you and b) it will ultimately help you to understand how to create repetitive code by using functions if you were to do it yourself.[/quote]

Thanks alot for the explanation. I will give it a go and let you know.

Peace

Mike