PDA

View Full Version : Particle System - Fireworks



danieray
July 11th, 2008, 09:28 AM
Hi - I'm trying to create a fireworks background using as3. I had found one tutorial that looks great, but uses as2 and i'm having trouble converting it to as3. i've done all of the lynda.com tutorials on particle systems, but still can't quite figure out how to get the firework working correctly.

here's the as2 fireworks that i like: http://www.wipeout44.com/tutorials/flash_fireworks.asp

The as2 code used is:

var numOfParticles:unit = 25;
var particles_ary:Array = [];

function updateStage(event:Event):void
{
if(particles_ary.length < numOfParticles)
{
var bluebit:Bluebit = new Bluebit();
addChild(bluebit);
bluebit.rotation = Math.random() * 360;
bluebit.alpha = Math.random(30) + 80;
bluebit.scaleX = 50 + Math.random(60);
bluebit.scaleY = 50 + Math.random(60);
gotoAndPlay(random(5));
}
}

Can anyone direct me to a tutorial that would help me figure out how to update this as2 to as3?

Thanks!

sekasi
July 11th, 2008, 09:39 AM
what part of that code are you having problem converting? btw that doesnt look like AS2 to me :P

danieray
July 11th, 2008, 11:56 AM
I pasted the code from the wrong file... i have so many files that i've been working from... the code i previously pasted was something i tried, but didn't work in as3. this is the original as2 code:

for (n=8; n<50; n++) {
duplicateMovieClip("particle", "particle" add n, n);
setProperty("particle" add n, _rotation, random(360));
setProperty("particle" add n, _alpha, random(30)+80);
setProperty("particle" add n, _xscale, 50+Number(random(60)));
setProperty("particle" add n, _yscale, 50+Number(random(60)));
tellTarget ("particle" add n) {
gotoAndPlay(random(5));
}
}


thanks for noticing!


what part of that code are you having problem converting? btw that doesnt look like AS2 to me :P

flobster
July 11th, 2008, 05:26 PM
Sorry, i cannot help you with your code example, but if you want to create fireworks particle effects, you might have a look at http://flintparticles.org.

amitkhanna
September 19th, 2010, 08:16 PM
Just in case if someone is looking for a working code, this is how I made it work.

"BB" is the class name (like linkage ID in AS2) of the movieclip in the library

for (var n:int=8; n<50; n++) {

var bluebit:BB = new BB();
addChild(bluebit);

addChild(bluebit);
bluebit.rotation = Math.random() * 360;
bluebit.alpha = Math.random() * .9;
bluebit.scaleX = .7 * Math.random();
bluebit.scaleY = .7 * Math.random();
gotoAndPlay(Math.random());

}


Cheers,
ak