Jump to content
Search Community

[noob question] Sequencing events

goonzy test
Moderator Tag

Recommended Posts

Hi all,

 

This might sound like a very dmb question but even looking thru the foru m i could not get an answer i would understand. (I'm a early beginner in AS3 and coding in general)

 

basically I'm trying to sequence two sets of events, triggere by completion of each other. I thought that using the onComplete trigger would do the job but it does nto seem to.

 

my code is like that:

 

function double_front(){ // DOUBLE COPPER DEVANT ET TRIPLE DERRIERE PREMIERE MOITIE
TweenMax.allFromTo([red_double_2, red_double_1], 1.5, {y:16,scaleY:0.8,colorMatrixFilter:{brightness:1}}, {y:100, scaleY:1, colorMatrixFilter:{brightness:1.2},repeat:-1,onComplete:double_back, delay:0.4,  ease:Sine.easeIn},0.4);

}

function double_back (){
TweenMax.allFromTo([red_double_1, red_double_2], 1.5, {y:100,scaleY:1,colorMatrixFilter:{brightness:1}}, {y:200,scaleY:0.8, colorMatrixFilter:{brightness:1.2}, repeat:-1,onComplete:double_front,  ease:Sine.easeOut},0.4);

}
double_front()

 

the 1st function runs OK, but the second is never triggered... what am I doing wrong?

 

(absically, I have to do this 1/2 way through a move where a clip has to go in front of the other.. so if there's another solution to do it, I'm also open :))

Link to comment
Share on other sites

I see two problems:

 

1) You're using an onComplete instead of the onCompleteAll parameter. Remember, anything you define in the toVars and fromVars will be applied to ALL of the tweens that get created. So if you're tweening 2 objects and you out an onComplete in there, the onComplete will get called twice (once for each tween when it finishes). There's an onCompleteAll parameter for the TweenMax.allFromTo() that will fire after ALL of the tweens have completed. See the ASDocs for details, but it's like TweenMax.allFromTo([objects], 1, {...fromVars...}, {...toVars...}, 0, myFunction);

 

2) You set the repeat on your tweens to -1 which means they'll repeat forever! So in your code, the onComplete never gets called because the tweens never end - they keep repeating. Remember, onComplete fires after the tween fully completes (including any repeats).

Link to comment
Share on other sites

In any cas I'll have to "ungroup" all clips as I can't find a way to change the displaylist order easily for the result I'm after. I'll try another solution with Tweenlinemax but the event "flow" is a bit hard for me to recreate... It might help for me to visualise it on a real timeline before trying to do it in "code" :)

 

Thanks for the reply in any case, I definitely have to go deeper in the AS doc but for a beginner like me, it's rather overwhelming :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...