Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to get the global position of the movieclip

Posted on 2003-10-24
2
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 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.

722 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