Val Head - Designer, Consultant and Speaker.

A basic custom class with AS3

These files are from my presentation at the Pittsburgh Flash User Group (PittMFUG) tonight.

There are two sets of example files, both showing very basic custom events in AS3 — hence the name “BareBonesEvent”.

The first set (01 really basic) is an example of BareBonesEvent that is fired after the mouse is clicked 5 times. Nothing fancy there at all. But, if you’re looking for minimal custom event code, this is it.

The second set (02 basic wProperty) steps it up just a little. The BareBonesEvent is dispatched after the mouse is clicked five times again. But this time we also move a graphic a few pixels and pass the graphics new x position along with the event object.

BareBonesEvent sample

ETA: If you’re wondering what happens if you don’t override the clone method, there’s a post on the bit-101 blog that explains a bit about what could happen: bit-1o1

  • danthepizzaman

    Thanks for this, exactly what I was looking for. Simple and effective!

  • danthepizzaman

    Hi, on the second example, if you dont add “_xPos = xPos;” in the constructor of the Event, 0 will always be displayed and passed to the listener.
    thanks again!

  • val

    thanks. glad you found it useful!