# Reassign button actions

**URL:** https://forum.kirupa.com/t/reassign-button-actions/262404
**Category:** Uncategorized
**Created:** [June 5, 2008, 5:29pm UTC](https://forum.kirupa.com/t/reassign-button-actions/262404 "2008-06-05T17:29:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bpdp](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@bpdp](https://forum.kirupa.com/u/bpdp)
#### Post date: [June 5, 2008, 5:29pm UTC](https://forum.kirupa.com/t/reassign-button-actions/262404/1 "2008-06-05T17:29:34Z")

</div>

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:

```auto

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:

```auto

_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!

---

<div class="post-metadata">

### Author: ![bpdp](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@bpdp](https://forum.kirupa.com/u/bpdp)
#### Post date: [June 5, 2008, 6:17pm UTC](https://forum.kirupa.com/t/reassign-button-actions/262404/2 "2008-06-05T18:17:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)
#### Post date: [June 5, 2008, 11:58pm UTC](https://forum.kirupa.com/t/reassign-button-actions/262404/3 "2008-06-05T23:58:19Z")

</div>

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

something like this should work:

```auto

// 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"});
};

```
