Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
iconofsin

code execution order

Recommended Posts

I am a begginer at both AS3 and tweenlite so sorry if this question seams simple

I have built a script by following a tutorial and modifying it to meet my needs (not easy if you know almost nothing about AS3)

 

The script has a container full of child objects which is programed to rotate when the mouse is moved. When a child object is clicked on it zooms in.

While zoomed in I do not want the choosen child object to rotate with the mouse anymore so I have used stage.addchild to seperate it from its pearent at this point.

 

anyway i want the selected child to move to the centre and resize while still a child of the rotating object because 0 for both the stage and the container are always the same location but because the container rotates dynamically all other locations are not the same part of the screen for both which means moving the child object to the stage before its location is 0 would cause an instant jump from one part of the screen to another.

at this point it will change to being a child of the stage so that it no longer rotates

since its rotation is 0 but the pearent objects rotation always changes there is a sudden jump from its old rotate property which is 0 relative to the pearent object to its new rotate property which is 0 relative to the stage so i will cover this up by rotating it arround very very fast so that the sudden change cannot be seen.

 

this is the relevant part of the code

 

---------------------------

 

private function scaleUp(mc:MovieClip):void

{

inFocus = mc;

 

TweenLite.to(mc, 3, {

scaleX:0.5,

scaleY:0.5,

x:0,

y:0,

rotationY:360,

rotationX:360,

ease:Expo.easeInOut

});

 

stage.addChild(mc);

mc.enlarge.alpha = 0;

mc.x = 0;

mc.y = 0;

}

 

--------------------------------

 

my problem is that It appears that all of the none tweenlite code is executing before the tweenlite code does no matter which order i put the commands in

 

i guess this is because the ordinary AS3 commands take an instant to compleate but the tweenlite ones take 3 seconds

how can I prevent the ordinary AS3 commands which come after the tweenlite commands from running before the tweenlite animation ends (that is stage.addChild mc - mc.y =0)

 

i have come across a tween comand called onComplete but i cannot figure out how to use them (i am new to AS3 remember)

 

perhaps there is a way to pause the execution of the code for 3 seconds, since 3 seconds is the lengh of the tween.

Link to comment
Share on other sites

using your example;

 

private function scaleUp(mc:MovieClip):void

{

inFocus = mc;

 

TweenLite.to(mc, 3, {

scaleX:0.5,

scaleY:0.5,

x:0,

y:0,

rotationY:360,

rotationX:360,

ease:Expo.easeInOut,

onComplete:moveStuff,

onCompleteParams:[mc]

});

 

function moveStuff(_clip:Sprite):void

{

stage.addChild(_clip);

_clip.enlarge.alpha = 0;

_clip.x = 0;

_clip.y = 0;

}

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.
×