# Event handlers in MX

**URL:** https://forum.kirupa.com/t/event-handlers-in-mx/28659
**Category:** Uncategorized
**Created:** [August 16, 2003, 8:38am UTC](https://forum.kirupa.com/t/event-handlers-in-mx/28659 "2003-08-16T08:38:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Neo\_Geo](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@Neo\_Geo](https://forum.kirupa.com/u/Neo_Geo)
#### Post date: [August 16, 2003, 8:38am UTC](https://forum.kirupa.com/t/event-handlers-in-mx/28659/1 "2003-08-16T08:38:00Z")

</div>

is event handlers make our life easier or not?

let say i have a MC named “A1”  
now i apply AS to A1

[AS]  
A1.onPress = function() {  
function that make MC move from A to B  
};  
[/AS]

now i need 10 more copies of A1  
when i duplicate (copy Paste) this MC,  
only i will follow the actionscript, the other will not.

do i need to make each one of the movieclip their own actionscript? can it just be one to control all 10 identical things?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 16, 2003, 9:23am UTC](https://forum.kirupa.com/t/event-handlers-in-mx/28659/2 "2003-08-16T09:23:14Z")

</div>

I’ve used

```auto

MovieClip.prototype.onEnterFrame = function () {
//your function for ALL movieClips
}

```

before, but I’ve never tried using that with a button to tell it to go, but I figure it could be done.

I did this once before too:  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25285&highlight=firework](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25285&highlight=firework)

On like the forth post or something, there’s a fla that uses a mouseDown function - that might help too.

Lost In Beta’s good with the prototype functions!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 16, 2003, 1:42pm UTC](https://forum.kirupa.com/t/event-handlers-in-mx/28659/3 "2003-08-16T13:42:54Z")

</div>

can prototype control all movie clip?

as you can see in my attachment, only one box respond  
the other one have exactly the same properties but do not change its alpha

[AS]  
box1.onRollOver = function() {  
this.\_alpha = 30;  
};  
box1.onRollOut = function() {  
this.\_alpha = 100;  
};  
[/AS]

2 boxes with instance name “box1”. Why don’t both of this box change?  
It is a problems when you have many boxes.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 21, 2003, 2:31pm UTC](https://forum.kirupa.com/t/event-handlers-in-mx/28659/4 "2003-08-21T14:31:43Z")

</div>

Sorry it’s taken so long to respond. Found an old email of this post…

> can prototype control all movie clip?

Yes.  
I have an example at home that I’ll post if you want it still. I also wouldn’t have two objects with the same instance name, I think that would cause more harm than good.

And then back on your original question, I usually will put the actions _on_ the movieClip that’s going to be duplicated, that way the code gets copied with each duplication:

```auto

onClipEvent(enterFrame){
_x+=3;
//whatever makes your movieClip move
}

```

Hope that (still) helps…(-:
