Archive for the 'Classes' Category

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:

  1. ButtonEvent.CLICK
  2. ButtonEvent.UP
  3. ButtonEvent.DOWN
  4. ButtonEvent.OVER
  5. ButtonEvent.OUT
  6. ButtonEvent.DRAG_OVER
  7. ButtonEvent.DRAG_OUT
  8. ButtonEvent.RELEASE_OUTSIDE
  9. 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:

ButtonUtil.zip

« Prev

  • Friends

  • Props

  • Donations

  • website counter
  • Archives

  • Feedburner