Event handlers in MX

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?

I’ve used


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

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!

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.

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:


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

Hope that (still) helps…(-: