Solved

how to get the global position of the movieclip

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

705 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

19 Experts available now in Live!

Get 1:1 Help Now