Reassign button actions

Hi All,
I have rollOver, rollOut, and Release actions on several buttons. I want to be able to keep the same buttons but attach different actions depending on what section of the site the user is in.

I have something like:


myClip.onRollOver = function():Void  {
            this.swapDepths(5000);
            Tweener.addTween(this, {_xscale:110, _yscale:110,
                                     _x:xArray[substring(this,12)] - 10, _y:yArray[substring(this,12)] - 9,
                                    time:1,
                                    transition:"easeOutElastic"
                                });
        };

and I want to change to:


_root['box'+i].onRollOver = function():Void  {
            Tweener.addTween(this, {_y:newArray* + 100,
                                    time:.1,
                                    transition:"easeOutElastic"
                                });
        };

I tried just reassigning it and also tried _root[‘box’+i].onRollOver = function():Void {null}
before reassigning it. neither worked. any help would be great. thanks!

Sorry it looks like it was reassigning the actions… it just didn’t like my array for some reason. looking into it now. Thanks for everyone who took a peek.

your iterator “i” - won’t be captured within the onRelease event in your loop.

something like this should work:


// assign a property on the clip to  store the iterator within
_root['box'+i].btnid = i;
_root['box'+i].onRollOver = function():Void  {
    // retreive btnid within the button event
    Tweener.addTween(this, {_y:newArray[this.btnid ] + 100, time:.1, transition:"easeOutElastic"});
};