A basic custom class with AS3
January 17th, 2008
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.
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




3 Comments
danthepizzaman Says:
Thanks for this, exactly what I was looking for. Simple and effective!
December 9th, 2008 at 7:15 am
danthepizzaman Says:
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!
December 9th, 2008 at 7:44 am
val Says:
thanks. glad you found it useful!
December 9th, 2008 at 8:44 am