# Smoking out AS2 for AS3

**URL:** <https://forum.kirupa.com/t/smoking-out-as2-for-as3/269465>\
**Category:** flash\
**Created:** [August 28, 2008, 12:19am UTC](https://forum.kirupa.com/t/smoking-out-as2-for-as3/269465 "2008-08-28T00:19:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_in\_drag](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@mike\_in\_drag](https://forum.kirupa.com/u/mike_in_drag)\
**Post date:** [August 28, 2008, 12:19am UTC](https://forum.kirupa.com/t/smoking-out-as2-for-as3/269465/1 "2008-08-28T00:19:39Z")

</div>

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/](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):

```auto
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:

```auto
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](http://www.cynical-forum.com/media/gunsmoke.swf). 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.
