Solved

how to get the global position of the movieclip

Posted on 2003-10-24
2
199 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

803 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