• November 14, 2006

    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);

No comments yet.

Have your say:

 
This blog is Gravatar friendly. Don't have Gravatar? Get one fast!
 

Proudly running on Word Press, and above all, proudly using Comic Sans.

Nivas.hr © Copyright 2009    All right reserved    Made in Croatia Yeah, we made our own site!Nivas.hr