I’ve been looking for a fairly decent smoke tutorial for a while and did come across this one:
http://www.pixelhivedesign.com/tutorials/Realistic+Flash+Smoke+Effect/
however, this didn’t really help as i want to do all of my coding in AS3. so i went out to convert this (AS2):
fadeSpeed = 1;
floatUpSpeed = 2;
this.onEnterFrame = function ()
{
d = this.getNextHighestDepth();
aPuff = attachMovie("aPuff", "aPuff" + d, d);
aPuff._xscale = aPuff._yscale = 10;
aPuff._x = Math.random() * 5;
aPuff.gotoAndPlay(Math.round(Math.random() * 20));
aPuff.onEnterFrame = function ()
{
this._xscale = this._yscale = this._yscale + fadeSpeed;
this._alpha = this._alpha - fadeSpeed;
this._y = this._y - floatUpSpeed;
if (this._xscale >= 100)
{
this.removeMovieClip();
} // end if
};
};
Now after attempting to convert this to AS3 i came up with this:
var fadeSpeed:Number = new Number(1);
var floatUpSpeed:Number = new Number(2);
var puff:MovieClip = new aPuff();
this.addEventListener(Event.ENTER_FRAME, smokeStart, false, 0, true);
function smokeStart(evt:Event):void{
addChild(puff);
puff.scaleX = puff.scaleY = 10;
puff.x = Math.random() * 5;
puff.gotoAndPlay(Math.round(Math.random() * 20));
puff.addEventListener(Event.ENTER_FRAME, moveSmoke, false, 0, true);
function moveSmoke(evt:Event):void{
this.scaleX = this.scaleY = this.scaleY + fadeSpeed;
this.alpha = this.alpha - fadeSpeed;
this.y = this.y - floatUpSpeed;
if (this.scaleX >= 100);
{
puff.removeEventListener(Event.ENTER_FRAME, moveSmoke);
}
}
}
Now i get to see the smoke, but not in the same way, just like this. Can someone take a brief glimpse over what i have done and give me a pointer as to where i may have gone wrong.
Thanks in advance, Mike.