3D Particle Effect – Flash CS4 Tutorial
Flash Tutorial December 21st, 2008In today's video tutorial, I'll show you how to create an ActionScript 3D particle effect that causes multiple stars to animate out in all directions in 3D space. Here is the ActionScript for this tutorial:
var container:MovieClip = new MovieClip(); addChild(container); root.transform.perspectiveProjection.fieldOfView = 120; addEventListener(Event.ENTER_FRAME, addStar); function addStar(e:Event):void { var mc:star = new star(); mc.x = stage.stageWidth / 2; mc.y = stage.stageHeight / 2; mc.z = 0; mc.xVel = Math.random() * 4 - 2; mc.yVel = Math.random() * 4 - 2; mc.zVel = Math.random() * 4 - 2; mc.count = 0; container.addChild(mc); mc.addEventListener(Event.ENTER_FRAME, animate); } function animate(e:Event):void { e.currentTarget.x += e.currentTarget.xVel; e.currentTarget.y += e.currentTarget.yVel; e.currentTarget.z += e.currentTarget.zVel; e.currentTarget.count++; if (e.currentTarget.count >= 100) { e.currentTarget.removeEventListener(Event.ENTER_FRAME, animate); container.removeChild(MovieClip(e.currentTarget)); } }


January 31st, 2009 at 11:28 am
Awesome tutorial…..It has really helped a lot…thanks a lot…..keep going!!!
February 22nd, 2009 at 5:52 pm
Great tutorial!
March 9th, 2009 at 5:22 am
It would be great if the stars would topple end over end randomly, that would be awesome!
Great tutorial.
March 15th, 2009 at 10:10 am
Thanks so much for your great tutorials. Just wanted to let you know someone really appreciates them.
March 16th, 2009 at 3:53 am
Wow. Thanks for that great tutorial. Yeah, what zenseeker said. This is too cool.
Can’t wait to play around with it.
April 10th, 2009 at 2:10 pm
Hey, this is a great tutorial man! Thanks a lot
May 6th, 2009 at 11:20 am
i have a bit of a problem … i get this error back saying this:
1119: Access of possibly undefined property perspectiveProjection through a reference with static type flash.geom:Transform. ->
root.transform.perspectiveProjection.fieldOfView = 120;
May 6th, 2009 at 11:22 am
sorry for double posting… but i’m in a very big hurry…and i don’t know how to come to a solution… help please
May 10th, 2009 at 7:53 pm
Hi Craig,
Great Job!
once you maximize the window the center does not propogate to center,
the instance of star movieclip “mc” changes you might have noticed.
thank you,
Sagir
May 31st, 2009 at 11:25 am
Great tutorial. You are an awesome teacher.
June 5th, 2009 at 11:10 am
how can I add text without it being behind the effect.
June 12th, 2009 at 9:32 am
hello, great tutorial
however i was inputting the codes and i thought i had it all set right,and i tested it and i only had the single star the in middle of the screen????
July 28th, 2009 at 2:36 am
Thanks for the tutorial!
However I was wondering how I could incorporate the effect into a tween. I would like to have the effect motion tween over a background layer. Is this possible?
Thanks,
-A
July 29th, 2009 at 9:49 am
Great tutorial.
How can I have this play behind other graphics on the stage? I have a logo centered on the stage and what similiar stars behind the logo.
November 24th, 2009 at 7:33 am
awesome job and excellent video explanation
November 28th, 2009 at 11:10 am
Man you just rock. I am really happy to visit your website.
I know how to do lots of interesting effects in after effects but when it comes down to flash then my knowledge is not so good. But know i think that i can do it in flash also!!! Please post some more tutorials. The best part of this tutorial is that everything is done using as3.
December 10th, 2009 at 12:13 pm
Excellent tutorial! I have a question about how to unload this when a user hits a replay button. The 3D particle effect stays on screen. What code should I add and where?
January 1st, 2010 at 12:51 am
i’m new to as3 thanks for yur tutorial
very few lines yet so fabulous understanding thanks a lot
January 3rd, 2010 at 5:56 am
thx i will use it on my future project
January 8th, 2010 at 4:40 am
Thank you very much !
January 31st, 2010 at 9:22 am
Nice tutorial
It does not appear in the centre of the window when it’s maximized
Thanks
February 3rd, 2010 at 7:50 am
Scuse-me I don’t write enghish very well.
How to put this program without the loop and place not on stage but in a window of 200px by 500px
February 17th, 2010 at 5:35 am
thanks…
February 21st, 2010 at 9:19 am
Hi,

great tutorial for a newbie like me
is it also possible to have this on a timer even instead of the enter frame event ? i added a button to start the animation but i can’t figure out how to access the variables outside the function. I would like the animation to start with my button and run for a certain amount of seconds.
Any push in the right direction would be great
Eddy.
March 14th, 2010 at 12:37 pm
Thenks Man