[quote=RonH;2336639]I don’t quite understand how you’d even do something like that. Do you just practice particle effects a lot? I had gotten pretty comfortable with myself in AS2, but after seeing something like that where I wouldn’t even know where to start, I guess I kind of realize how much I don’t know.
I could put dots on the screen and have them move around randomly, but I couldn’t make them follow a non linear path, let alone have smoke trail after them. Would you mind giving me some tips? Would you mind posting your source code if you just did it for fun?[/quote]
I dunno about his code, but I had a couple minutes so I made an example for you:
Demo: http://ragonadesign.com/particles/particles.html
**Source:
**
//imports
import gs.TweenMax;
import fl.motion.easing.*
//particle variables
var numParticles:int = 100;
var particleSize:Number = 5;
var particleArray:Array = [];
//animation timer variables
var moveTimer:Timer = new Timer(2000);
//'smoke' variables
var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x000000);
var bm:Bitmap = new Bitmap(bmd);
var bf:BlurFilter = new BlurFilter(2, 2, 1);
var cmf:ColorMatrixFilter = new ColorMatrixFilter([1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0 ,0 ,0.75 ,0]);
init();
function init():void
{
addParticles();
addTimer();
addSmoke();
}
function addParticles():void
{
for (var z:int = 0; z < numParticles; z++)
{
var curParticle:Sprite = buildParticle(particleSize);
//
addChild(curParticle);
//
particleArray.push(curParticle);
}
}
function addTimer():void
{
moveTimer.addEventListener(TimerEvent.TIMER, animateParticles);
moveTimer.start();
}
function addSmoke():void
{
addChild(bm);
addEventListener(Event.ENTER_FRAME, drawSmoke);
}
function buildParticle(size:Number):Sprite
{
var retSprite:Sprite = new Sprite();
var partX:Number = Math.random()*stage.stageWidth;
var partY:Number = Math.random()*stage.stageHeight;
//
retSprite.graphics.beginFill(Math.random()*0xFFFFFF, 1);
retSprite.graphics.drawCircle(0, 0, size * 0.5);
retSprite.graphics.endFill();
//
retSprite.x = partX;
retSprite.y = partY;
return retSprite;
}
function animateParticles(e:Event):void
{
for (var z in particleArray)
{
var curParticle:Sprite = particleArray[z];
var animTime:Number = Math.random() * 3 + 1;
var partX:Number = Math.random()*stage.stageWidth;
var partY:Number = Math.random()*stage.stageHeight;
var thruX:Number = Math.random()*stage.stageWidth;
var thruY:Number = Math.random()*stage.stageHeight;
//
TweenMax.to(curParticle, 2, {x: partX, y: partY, bezierThrough:[{x: thruX, y:thruY}], ease:Linear.easeNone });
}
}
function drawSmoke(e:Event):void
{
bmd.draw(this);
bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), bf);
bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), cmf);
}
Just drop that into a blank FLA, and it’ll do the rest. This is a really basic example that I made in about 10 minutes, so you’ll have to excuse any random imperfections. I used [U]TweenMax[/U] as the tweening engine.
:thumb: