ButtonUtil Class (AS3)
Reynaldo December 18th, 2007
Hi all!
I was cleaning up my desktop and found a nifty little pair of classes I coded. I created a ButtonUtil class (and an accompanying ButtonEvent class) which piggybacked parameters for the assigned function listening to the button event.
I basically created a Custom Event class and wrapped the regular AS3 Mouse Events in a the util class. It’s very simple to use and works great for me. Here is how it’s used:
[EDIT]:
Events:
- ButtonEvent.CLICK
- ButtonEvent.UP
- ButtonEvent.DOWN
- ButtonEvent.OVER
- ButtonEvent.OUT
- ButtonEvent.DRAG_OVER
- ButtonEvent.DRAG_OUT
- ButtonEvent.RELEASE_OUTSIDE
- ButtonEvent.DOUBLE_CLICK
1 2 3 4 5 6 7 8 9 10 11 | import ButtonUtil; import ButtonEvent; var myBtn = new ButtonUtil(btnOnStage); myBtn.addButtonListener(ButtonEvent.CLICK, clickHandler, {msg:"Hello World!"}); function clickHandler($event:ButtonEvent):void { trace($event.params.msg) } |
You can grab the sample file and the classes here:



