DancingSamurai
06-27-2003, 04:33 PM
Hi, I'm trying to find an elegant way to attach the same onRelease method to every instance of a button symbol in my Flash MX library.
So I've created the library symbol, myButton, and clicked "Export for ActionScript". Not too sure what "Export in first frame does" but left in at the default (on). I placed a bunch of buttons where I wanted them.
Then I put this code in the buttons' parent (it's residing in a movie clip):
#initclip
function myButton(){};
myButton.prototype = new Button();
myButton.prototype.onRelease = function(){
//Code here
trace("myButton pushed!");
};
Object.registerClass("myButton", myButton);
#endinitclip
... which didn't work.
I solved the problem by nesting the button inside a movie clip and attaching actionscript to the button instance inside myButton_wrapper library symbol... but is there a more elegant way to do it?
So I've created the library symbol, myButton, and clicked "Export for ActionScript". Not too sure what "Export in first frame does" but left in at the default (on). I placed a bunch of buttons where I wanted them.
Then I put this code in the buttons' parent (it's residing in a movie clip):
#initclip
function myButton(){};
myButton.prototype = new Button();
myButton.prototype.onRelease = function(){
//Code here
trace("myButton pushed!");
};
Object.registerClass("myButton", myButton);
#endinitclip
... which didn't work.
I solved the problem by nesting the button inside a movie clip and attaching actionscript to the button instance inside myButton_wrapper library symbol... but is there a more elegant way to do it?