Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to get the global position of the movieclip

Posted on 2003-10-24
2
Medium Priority
?
206 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month6 days, 12 hours left to enroll

783 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