Solved

how to get the global position of the movieclip

Posted on 2003-10-24
2
198 Views
Last Modified: 2012-06-21
Hello, I have one movieclip A within another movieclip B , and I use button to move movieclip B up and down. Then how can I get the position value of the movieclip A ( the global position not the relative position to movieclip B ).

I have the movieclip A in movieclip B with the relative position of x: -15.8 and y: -22.8

Then I have the button for moving movieclip B, say moving up with the action like

on (release) {
_root.B._y -= 5;
}

So the movieclip A is moved at the same time within movieclip B
Then how should I write the code to get the global position of movieclip A then ?
Thanks very much in advance and wait for your reply!
0
Comment
Question by:SBUH
2 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 50 total points
ID: 9613759
IN the first frame of you movie write:

MovieClip.prototype.toGlobal = function(reference)
{
      var point = new Object();
      point.x = reference._x;
      point.y = reference._y;
      this.localToGlobal(point);
      return point;
}

Then, when you want to know the global position of A, write:

trace("X pos of A movieclip: " + B.A.toGlobal(_root).x)
trace("Y pos of A movieclip: " + B.A.toGlobal(_root).y)
0
 

Author Comment

by:SBUH
ID: 9641510
Hello, thanks for your code, it works perfect. Thanks a lot !
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now