You can do this:
myButton_btn.onRelease = myButton_btn.onPress = myButton_btn.onRollOver =
function(){
doStuff();
}
In my experience that doesn't work. It *should*, but for some reason,
the function never gets assigned to most or all of the events. Better is to
use Delegate.
import mx.utils.Delegate;
function doStuff(){
// code...
}
myButton_btn.onRelease = Delegate.create(this,doStuff);
myButton_btn.onPress = Delegate.create(this,doStuff);
myButton_btn.onRollOver = Delegate.create(this,doStuff);
What that does is assign the function "doStuff" to the event, and it
will be executed within the scope specified (in the above example, "this" is
the scope). It's still 3 lines, but at least it's not a new function
defenition for each line, it's just an assignment.
ryanm
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com