In 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)); } }















Mearvin
Awesome tutorial…..It has really helped a lot…thanks a lot…..keep going!!!
Flash Designer
Great tutorial!
Jon Mulligan
It would be great if the stars would topple end over end randomly, that would be awesome!
Great tutorial.
Zenseeker
Thanks so much for your great tutorials. Just wanted to let you know someone really appreciates them.
Rapi
Wow. Thanks for that great tutorial. Yeah, what zenseeker said. This is too cool.
Can’t wait to play around with it.
Sluff
Hey, this is a great tutorial man! Thanks a lot
cretzuuu
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;
cretzuuu
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
Sagir
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
J Z
Great tutorial. You are an awesome teacher.
martin
how can I add text without it being behind the effect.
steve
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????
Andrew
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
Joe
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.
Michelle
awesome job and excellent video explanation
Manndy
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.
Alex
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?
Karthi
i’m new to as3 thanks for yur tutorial
very few lines yet so fabulous understanding thanks a lot
lektira
thx i will use it on my future project
corinne
Thank you very much !
Kanishka
Nice tutorial
It does not appear in the centre of the window when it’s maximized
Thanks
chico crevin
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
thail long quan
thanks…
Eddy
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.
Turkis
Thenks Man
Greg
Excellent tutorial!
Can’t wait to try it.
Luz Elena
Saludos desde Barcelona, ¡¡¡ Exelentes tutoriales !!!!
Gracias
JJ
Should be like this (for centering)
mc.y = stage.height / 2;
mc.y = stage.height / 2;
John
@ manndy…obviously you didnt read the top of the page…this is done in cs4 and not cs3 or as3 as you out it lol
Great tutorial mate thanks
John
btw once you export the movie and then go fullscreen it stays in the middle
Free Online Games
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;
nailer
Great job Craig. I’m just starting out and have learned much from watching you. The effect applied to your image in the chair is very intersting. Is there a tutorial for that?
elevated
As always you are helpful as ever with a great tutorial. Can you or will you pass on the “how” of the transition effect you used for the image at the clip start.
Tracey
Thanks so much! I really enjoyed this. I don’t even have cs4 yet, but i can’t wait (now that cs5 is out, oh well). I am just now learning actionscript so it was great to be able to understand what your directives were.
EssellGop
be happy and love. kiss
DancingKim
Howdy, i’m a professional dancer. i’d like to make a showreel to get my promotions. I also prefer to use some animation. Can someone suggest me a good animation studio, but possibly not very expensive? I’m here for 3 months for a tour.
Love
Kim.
Angielski wrocław
great tutorial on cool effect. thanks and keep it comming!
profeivan
Great tutorial man. Well explained. Thanks for taking your time to share this with the Flash community. Best regards from Colombia
Anonymous
Another great tutorial! Though, I wonder if it’s possible to fade out the particles before actually removing them.. I’ve experimented different methods, but I haven’t succeeded yet. The reason being my being quite new to actionscript 3.0..
Elza Pereira
Your tutorial is excellent. I am developing my portfolio and I believe in using particles.
I am Brazilian, I am learning English because I love Flash/AS3.
Thank you. Big hug.