Globalize MovieClip Prototype          

Clasificado bajo: AS2 (deprecated), Prototipos — drus @ 3:02 am

Este prototipo simplifica el manejo de coordenadas de movieClips anidados, al devolver la posicion absoluta del clip.

Actionscript:
MovieClip.prototype.globalize = function() {
    var sum:Array = new Array(this._x, this._y);
    var parent:MovieClip = this._parent;
    while (parent) {
        sum[0] += parent._x;
        sum[1] += parent._y;
        parent= parent._parent;
    }
    return sum;
};
//Uso:
trace(my_mc.globalize()[0]);   //devuelve la coordenada _x absoluta
trace(my_mc.globalize()[1]);   //devuelve la coordenada _y absoluta




Siguiente página »

AS_toolKit | Powered by WordPress | Skinned by Drus Unlimited | RSS Feed | Copyleft