Giles,

Thank you for this excellent explanation. I'd get confused by this too from time to time. Especially because there were different ways to use it. Now I have another good way to explain it.

If you are in HTML you already know what localToGlobal is. Just different terms. Local to global is a way of saying relative to absolute. I would have understood this earlier if the function was renamed relativeToAbsolute or relativePositionToAbsolutePosition.

Maybe some new functions should be made that would make more sense to people like me:

// returns point object with absolute (global) x and y of my_mc
var globalPosition:Object = my_mc.absolutePositionInStage()

// returns relative position of nested_child_mc to ancestor_mc
var relativePosition:Object = nested_child_mc.relativePositionTo(nested_child_mc._parent._parent) var relativePosition:Object = nested_child_mc.relativePositionTo(_root.parent_of_nested_mc)

maybe you could give an explanation of global to local?

judah


Giles Taylor wrote:

Say you have a movieClip called "A_mc" on the stage that you move to
x:20 y:20, then you have a movieClip in "A_mc" called "B_mc" that you
place at x:20 y:20.

When looking at the stage "A_mc" will be at x:20 y:20, but "B_mc" will
be at x:40 y:40.

However, if you ask what B_mc._x is then it will say 20 because it
relates it to it's parent movieClips registration point(x:0 y:0).

So to find out when "B_mc" actually is on the stage you use:
var myPoint:Object = {x:B_mc._x, y:B_mc._y}
B_mc.localToGlobal(myPoint);
Trace("myPoint is now relative to the Stage: (" + myPoint.x + ":" +
myPoint.y + ")");

So, in your case you would say:
var myPoint:Object = {x:MAP.springfield._x, y:MAP.springfield._y}
MAP.springfield.localToGlobal(myPoint);
Trace("myPoint is now relative to the Stage: (" + myPoint.x + ":" +
myPoint.y + ")");

Hope that help you "get" it.
Giles

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kurt
Dommermuth
Sent: 07 October 2005 11:39
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] localToGlobal ?

Hello,

How localToGlobal is to be used has confounded me from day 1.  I never
"get" it and usually end up doing things in some assbackwards way to
accomplish what I want.

Hopefully someone can put me out of my misery once and for all.

at least in terms of localToGlobal.

I have a an MC called MAP .  Within MAP I mark certain towns with nested
movie clips with unique names such as "springfield".

I want to pass a function located in _root the _x and _y values of
"springfield" and have the map move so "springfield" is in the center of
the stage.

I know this should be a simple task and yet I waste hours every time I'm
faced with this type of problem.

Hope I'm being clear.

thank you!
Kurt
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to