-
coordinates not tracing correctly
I'm having a very odd problem. I have a mc that is not at a specific coordinate, but it is NOT at 0,0. However, when I trace it's _x or _y it comes up at 0,0. I have double double check that I'm tracing the right mc.
I discovered this because I'm trying to use the mc as a target for a hittest and it wasn't working.
Any insight is great.
Thanks
-
Senior Member
is the clip nested inside any other clips? it sounds like you might be finding its position relative to the timeline of another movie clips instead of the main timeline.
-
Yes, it is nested inside another mc, but I've made very sure that I'm referencing the correct mc.
-
Senior Member
if you use something like,
_root.someClip.someOtherClip._x;
it will only find the position of someOtherClip relative to the origin of someClip.
you need to use the localToGlobal method to convert the coordinates to be relative to the main timeline.
for example, consider clip mc, on the main timeline (at the position 10, 10) inside mc is another clip named inner (positioned at the point 10, 10 inside mc)
code:
// actions in the frame that contains mc
trace("local coordinates = (" + mc.inner._x + "," + mc.inner._y + ")"); // (10, 10) the position of inner inside mc
var pt = {x: 0, y: 0}; // 0, 0 is the origin of the clip inner, we want to find where this point appears on the main timeline
this.mc.inner.localToGlobal(pt);
trace("stage coordinates = (" + pt.x + ", " + pt.y + ")"); // (20, 20) the position of inner relative to the main timeline
-
I can see where this method would be helpful in some instances, but I think that is much more in depth than i need it to be...let me be more specific about my set up....
On the main timeline i have mcGame..inside mcGame is mcMallet and mcMoles...inside mcMoles is mcMole1, mcMole2, mcMole3 and mcMole4..
mcGame
mcMallet
mcMoles
mcMole1
mcMole2
mcMole3
mcMole4
on mcMallet is a hittest because the user uses the mallet to hit the moles...on mcMallet I put trace(_parent.mcMoles.mcMole1._x)...this returns 0, however if I go to mcMole1 and click on it and look in the property window it shows the x coordinate at 117.5.
-
Senior Member
-
please email me directly and i will send you a link...marshall@marshallhansen.com...this is the only way i can do it as this is for a high profile client
-
Senior Member
you have mail
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|