View Full Version : scaling and moving movieclips
tdi
September 9th, 2008, 07:23 AM
hi all.
need urgent help with something.
i have 3 movieclips lined up horizontally on the stage. i want to do a few things;
- on each button rollover/rollout, the button scales up/down around 200% and 'pushes/pulls' the other buttons either side so that the distance between each one is maintained and there's not overlap.
- onclick, the button scales up about 400% and moves below the others. the gap is leaves gets 'filled' by the other buttons moving into its place.
i found a site that does pretty much exactly what i'm after - www.hansthedouble.com (http://www.hansthedouble.com).
help would be appreciated.
thanks
TDi
kipty
September 9th, 2008, 08:14 AM
I did something similar,
i had an array of all the movies i wanted to shift.
i used the Tween class for scale up the movieclips, added a MOTION_CHANGE listener to the Tween, then in the MOTION_CHANGE listener function loop thro all the movies, and set the position of the current MC to the x plus width of the prev MC. (if that makes sense)
something like
var _mc_List:Array(mc1, mc2, mc3 ...)//list of all moceis to shift
/**
* scaling handler
* called on Tween event MOTION_CHANGE
*/
private function _scaleUp(e:TweenEvent):void
{
_shiftWhenScaling(Sprite(e.currentTarget.obj));
}
/**
* shift the x positions of each thumbnail according the previousl thumbs x position and width
*
*/
private function _shiftWhenScaling(t:Sprite):void
{
var scalingMC:Sprite = t;
var thisMC:Sprite;
var prevMC:Sprite;
var tLen:uint = _mc_List.length;
var tIndex:Number;
//
for(var i:uint = 0; i < tLen; i++)
{
thisMC = _thumbnailList[i];
prevMC = _thumbnailList[i-1];
//
if(prevMC != null)
{
thisMC.x = prevMC.x + prevMC.width;
}
}
}
not sure if it is the most efficient way, but it works
tdi
September 9th, 2008, 08:52 AM
hi kipty,
tried implementing your code as a test, but it threw up quite a few errors.
since i'm not fanstatic with actionscript, would you mind stepping through the code and pointing out where i may need to change/adapt it...
cheers
T.
Rundevo
September 9th, 2008, 09:08 AM
I would use the TweenLite class!
Your code will not be dynamic, so you´ll need to change the positions of all your objects, but it´s so easy using the TweenLite class, give it a try anyways!
http://blog.greensock.com/tweenliteas3/
kipty
September 9th, 2008, 09:31 AM
I am presuming you are using AS3, i put it in a fla, easier for both of us, hope it makes sense.
tdi
September 9th, 2008, 09:59 AM
thanks kipty - looks great!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.