Category:
developers journal
flash
GlobalToLocal / LocalToGlobal? Meet – localToLocal!
John Grden came up with great idea to deal with coordinate conversion in Flash – localToLocal! He first implemented it way back in Flash6.
class com.rockonflash.utils.CoordinateTools
{
public static function localToLocal(from:MovieClip, to:MovieClip, origin:Object):Object
{
var point:Object = origin == undefined ? {x: 0, y: 0} : origin;
from.localToGlobal(point);
to.globalToLocal(point);
return point;
}
}
Just use it to create your point object and you’re done:
var point:Object = CoordinateTools.localToLocal(from:MovieClip, to:MovieClip);