this is portable

A basic custom class with AS3

January 17th, 2008

flash 3 comments »

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

3 Comments

danthepizzaman Says:

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

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!

val Says:

thanks. glad you found it useful!

Leave a Comment

your name and email are required to post a comment. however, your email will NOT be published. All comments are held for moderation before they will be posted. You can thank our friends the spammers for that.