I have a movieclip that gets loaded into another container. The movieclip reads the mouse x & y position to resize a circle according to the mouse position - it works fine on its own, but when the movieclip is loaded into a container I think the actionscript is reading the container's x & y, not from the mc itself.
The code I'm using to read the mouse x & y is:
d = Math.sqrt(Math.abs(_root._xmouse-this._x)*Math.abs(_root._xmouse-this._x)+Math.abs(_root. _ymouse-this._y)*Math.abs(_root._ymouse-this._y));
It works out the distance of the mouse from the central point (centre of the circle movieclip.)
Like I say, it works fine on its own, but when in another container the _root is causing the x & y to be displaced. I've tried _lockroot, but that stops other stuff working properly in the movieclip (drag and drop.)
Is there another way I can directly access the x & y properties of the main movieclip without using _root?
I am not sure what the scenario is as far as where that code is relative to where the objects are, but when you place the mc inside a container, its _x and _y values are relative to the container at that point. So you probably either need to change from using the _root.xmouse to using the container._xmouse (etc), or make use of the localToGlobal() method to translate this._x to _root relative _x.
Thanks Ned - after reading your reply I had another look at the line and the relativity of it all (if that makes sense?) and I just removed the _root. So instead of referring to _root._xmouse I just use _xmouse on its own instead - it works fine now.
Thanks for your help!