PDA

View Full Version : Tween into position when a movie clip is automaticcally centered to stage



jeros10
March 14th, 2009, 02:53 PM
I hav movieclips in a flash document that i have autocenter when the stage is scaled code is something like this:

clients_mc.y = Math.round((stage.stageHeight/2)-15);

stage.addEventListener(Event.RESIZE, resizeClients);

function resizeClients(event = null){
clients_mc.y = Math.round((stage.stageHeight/2)-15);
};


any way to make it esae in to position or bounce, something?

snickelfritz
March 14th, 2009, 03:43 PM
You can try something like this.
Download TweenGroup (http://blog.greensock.com/tweengroup/) and set up a custom classes directory in AS3 prefs; place the "gs" folder in there.


import. gs.*;
import gs.easing.*;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeClients);

function resizeClients(event = null)
{
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
TweenLite.to(clients_mc, .5, {y:Math.round((sh/2)-15), ease:Bounce.easeOut});
}
stage.dispatchEvent(new Event(Event.RESIZE));

jeros10
March 14th, 2009, 04:25 PM
i get this:

1084: Syntax error: expecting identifier before dot. import. gs.*;


confused!

jeros10
March 14th, 2009, 06:12 PM
i figured it out:

import. gs.*;
import gs.easing.*;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeClients);

function resizeClients(event = null)
{
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
TweenLite.to(clients_mc, .5, {y:Math.round((sh/2)-15), ease:Bounce.easeOut});
}
stage.dispatchEvent(new Event(Event.RESIZE));
but is there a way to make it work on the x axis also?

snickelfritz
March 14th, 2009, 07:11 PM
remove the dot after import; it's a typo.
In the TweenLite function, specify the x: property:


TweenLite.to(clients_mc, .5, {x:100, y:Math.round((sh/2)-15), ease:Bounce.easeOut});