|
-
Find out global coordinates of a movie clip in order to animate it
I have a group of movie clips (sunglass1, sunglass2, ...) arranged in rows and columns within another container movie clip. Just beside this "gallery" there's a movie clip I call frame.
What I want to do is: when you click on a sunglassn movie clip, it has to be animated by a Tween which places it on the center of the frame from its initial location (no matter if I work with the coordinates of frame or with _root, I want to place it always on a specific location of the stage).
For an only child, it would be something like this:
PHP Code:
sunglass1.onPress = function() {
var animX:Tween = new Tween(this, "_x", Regular.easeIn, this._x, desiredEndPointX, 0.5, true);
var animY:Tween = new Tween(this, "_y", Regular.easeIn, this._y, desiredEndPointY, 0.5, true);
};
The problem is that those coordinates are the ones in its container, not their analog ones with regard to _root or frame.
I guess I have to use the localToGlobal method, but I don't know how to use it in this case.
Please, could somebody help me?
Last edited by Jazztronik; 03-12-2009 at 02:05 PM.
-
Maybe you can adapt this...
Code:
containerMC.sunglass1.onPress = function() {
var myPoint:Object = {x:200, y:100};
this._parent.globalToLocal(myPoint);
var animX:Tween = new Tween(this, "_x", Regular.easeIn, this._x, myPoint.x, 0.5, true);
var animY:Tween = new Tween(this, "_y", Regular.easeIn, this._y, myPoint.y, 0.5, true);
};
-
Many thanks dawsonk!! I was using just the opposite method!
Last edited by Jazztronik; 03-12-2009 at 02:39 PM.
Tags for this Thread
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
|