home subscribe to email updates subscribe to RSS updates

ActionScript 3 - First Steps

Last night I started my trip towards AS3 knighthood… and it was a little bumpy. I don’t know whether it was just me (quite likely) but it was much more of a mind-shift than I had anticipated.

I recently did a small job for an overseas client and they paid me in two ActionScript 3 books… I’ll post about these soon. Anyway, they arrived yesterday and I couldn’t put them down.

Michael Battle - ActionScript 3 Experiment - Particle Generator

Amongst a myriad of small syntactic differences, the display list rendering and the new event management model took the longest to get used to (edit: actually, there’s a lot more to it, but that’s a good start). Although now that I ‘get it’ to this extent, I can see the promise of how much better the overall tool will be. What took me a few hours to sort out and debug is that simply calling removeChild() is not enough to remove the object from memory… after reading about it here, it turns out that one needs to listen out for the EVENT.REMOVED event! Needless to say, neither of my books mentioned this.

So - for nothing more than plain hard proof that I did actually manage to get something done, here is a dramatically simplified version of the particle generator that you’ve seen here and here.

Update: There is a now a more recent version of this experiement here.

Instructions
Click and drag… (Flash Player 9 required)

This is spitting out 5 dots per frame, working at 31 frames per second. From the reading I’ve been doing around the web, AS3 brings around a 10x speed increase. This seems to be pretty close to what we’re seeing above in comparison to the previous versions.

Update
The source code is now available for download here. I’ve put a few comments in there to make it a little more obvious as to what’s going on. Remember, I’m new to AS3 so if you see something that can be done better, please let me know.


« mb3Dengine - update
AddThis Social Bookmark Button

Related Posts:

Comments:

Jesper said,

January 25, 2007 @ 1:38 pm

Wow, that’s really a big difference in performance. Any chance you be posting the source for this? Would be really fun to have a look at. Bet people ask you all the time though..

Michael said,

January 25, 2007 @ 1:50 pm

Hey Jesper - thanks for your comment. I’ll post the code for this as soon as I tidy it up… hopefully tonight or tomorrow.

I figure the two ActionScript books are incentive enough to keep giving back to the community. Thanks go to Damien and Reddoor.biz - great to work with.

Jesper said,

January 25, 2007 @ 2:53 pm

Thanks - that sounds great. I really enjoy reading your blog. Looking forward to follow your journey in the AS3 arena.

mel said,

January 27, 2007 @ 12:19 pm

I always think that flash expert=physicist+mathematician. They seem to need some art senses too nowadays. Or art works can be generated by a calculation? Analytical Artist! Nice reading your blog. It’s very informative. Look forward to reading more yr AS3 trial results.

Justin said,

May 21, 2007 @ 10:54 pm

Hi Michael,

I am working on a music visualisation tool, which utilises your fantastic particle engine.

I have modified it to attach movieClips with animations rather than drawing shapes. (the particle class now extends movieclip not shape)

I am experiencing a glitch in Flash though and was wondering if you could help. it involves certain animations refusing to be removed from the stage after death, though I have run traces and they seem to be removed from the particleGenerator class.

More here: http://www.kirupa.com/forum/showthread.php?t=261789

Simplified version minus the visualisation has been uploaded for you to see what I mean: http://www.soulwire.co.uk/example.zip

If you have any sugestions I would be very grateful.

Thank you for sharing your experiments. Its very interesting to browse your site.

All the best,

Justin

Michael said,

May 21, 2007 @ 11:09 pm

Hey Justin - I’m away on holidays at the moment so I don’t have access to anything to try and help out with your problem. I wont be back for another 3 weeks.

Hopefully someone else will lend a hand in the interim… and, if you do sort it out, please let us know what you’ve learned!

Good luck!

AJ said,

May 24, 2007 @ 7:45 am

Hi!

Nice, if somewhat verbose, code.

Something that had really helped me has been importing flash.geom.Point. This way there is no need to make your own distance, angle, etc. functions; you just use distance(p1, p2) and it sorts it out for you. Moreover, what have you used to compile this? I tried compiling it in Flash CS3 and got a massive FPS boost over the online version :S.

Michael said,

May 24, 2007 @ 3:10 pm

Thanks AJ - great tip regarding the Point class and the associated trig functions… I’m sure that will come in handy. If I remember correctly, I think I was trying to be deliberately verbose so that I didn’t exclude anyone regardless of expertise.

I used Flex Builder 2 to compile it… I didn’t know that CS3 compiled things ‘better’ than FB2… though I did know that things run much faster when not in a browser (and that IE runs flash faster than firefox etc). Is that what you’re seeing?

Justin said,

July 17, 2007 @ 8:30 am

Hello Michael :)

Just a very late update to let you know that I used your AS3 particle engine in a music visualisation script. There are several at http://www.disabled-algebra.co.uk/ but the one you helped me with is http://www.disabled-algebra.co.uk/ambiguous_phone_sex.html

Thanks again for the good work and most of all for sharing your talent.

All the best mate.

Michael said,

July 17, 2007 @ 8:51 am

Justin - that looks awesome! Congratulations! I love it.

I forgot about your earlier comment (that arrived when I was overseas) but it looks like you’ve got it all sorted.

I think you have just inspired my next blog post :)

Justin said,

July 28, 2007 @ 5:05 am

Cheers man, I’m glad you like it :)

Congratulations on the job at lightmaker by the way! they are an awsome company, I wish you the best of luck with it dude…

Walker Hamilton said,

September 20, 2007 @ 5:39 am

If you liked getting that info from jon, you might be interested to know his new blog is here: http://greenethumb.com

RSS feed for comments on this post · TrackBack URI

Leave a Comment



« mb3Dengine - update