-
using TWEEN to scale
just a quick one i am trying to enlarge a rectangle (box) using the Tween function in AS3 like so:
PHP Code:
tw = new Tween(box, "x", Strong.easeOut, box.scaleX, 2, 1, true);
tw.addEventListener(TweenEvent.MOTION_CHANGE, _syncScale);
function _syncScale($e:TweenEvent):void{
box.scaleX = box.scaleY = tw.position;
}
however when you scale it like this or with the "width" it scales it on one side, where as i want it to scale from the centre (like how things scale if you just hold the shift key when scaling in Flash)
but i cant figure out how.
thanks
Dan Hodkinson
-
trace("AKA: Biro Barna");
Maybe something like this:
PHP Code:
import fl.transitions.Tween; import fl.transitions.easing.*;
var toMouseX:Tween; var toMouseY:Tween;
var initialState:int = 1; var finalState:int = 2;
stage.addEventListener(MouseEvent.MOUSE_DOWN, onStagePress);
function onStagePress(event:MouseEvent):void { easingAnimation(); } function easingAnimation():void { this.toMouseX = new Tween(box, "scaleX", None.easeNone, this.initialState, this.finalState, .5, true); this.toMouseY = new Tween(box, "scaleY", None.easeNone, this.initialState, this.finalState, .5, true); this.initialState = this.finalState; this.finalState++; }
You have to scale both X and Y if you want the object to fully scale.
Hope it helped.
| Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro | WebLog: http://blog.wisebisoft.com/ |
| Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
| Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/ | By perseverance the snail reached the ark. |
-
thanks but with the scaleY i had that covered with:
box.scaleX = box.scaleY = tw.position;
which scales the x the same as the Y i believe.
also the mthod you showed me still just scales it "down + right" as opposed to from the middle and scaling it globally (up, down, left, right at the same time)
hope that makes a bit more sense.
Dan
-
trace("AKA: Biro Barna");
Ok, then I know what you are doing wrong. Both in my example and yours, be sure that you have the registration point of your movie clip centered. If you have the registration point at the TOP_LEFT or somewhere else then it will scale the object from there.
| Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro | WebLog: http://blog.wisebisoft.com/ |
| Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
| Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/ | By perseverance the snail reached the ark. |
-
ok then would you happen to know the code for that at all Plenary, after searching adobe i get this:
The default registration point is (0,0)
but it doesnt mention anything about where to change it.
thanks
Dan
edit: i think i have found a work around where i edit the movie clip of the box and move it into its centre point, but just wondering whether there is a better, cleaner version using code?
Last edited by danhodkinson; 02-27-2008 at 04:41 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|