PDA

View Full Version : How to transcribe this AS1 to AS2?


beeblebrox
06-26-2008, 10:16 AM
A long time ago I've made this nice rocket fumes effect
using code provided by a tutorial...

Now I want to build this effect into my new game.
But it doesn't work because of AS 1/2 differences.

any help how to transcribe the fumes script to AS 2 would be appreciated.

heres the code:


Mouse.hide();

function Sterne() {
this._x = _root._xmouse-5;
this._y = _root._ymouse+68;
this.pX = 0;
this.pY = 0;
this.onEnterFrame = function() {
this._x += this.pX;
this._y += this.pY;
this.pX += Math.random()*6-3;
this.pY += 1;
if (this._x>Stage.width || this._x<0 || this._y>Stage.height || this._y<0 || this._alpha<1) {
this.removeMovieClip();
}
};
}

Sterne.prototype = new MovieClip();

Object.registerClass("sClip", Sterne);
minAbstand = 1;

this.onMouseMove = function() {
var diffX = this._xmouse-posX;
var diffY = this._ymouse-posY;
var abstand = Math.sqrt(diffX*diffX+diffY*diffY);
if (abstand>minAbstand) {
attachMovie("sClip", "stern_mc"+i, i+500);
posX = this._xmouse;
posY = this._ymouse;
i++;
}
updateAfterEvent();
};


and here's the fla & swf:

Jeremy78
06-26-2008, 03:04 PM
this would be classified as1 but compatible with AS2 the differences are the added features in AS2 other than that this is AS2. I mean this is a pretty cool little file, there were a few things that I would do differently by adding a for loops etc but other than that it works with as2

beeblebrox
06-26-2008, 04:00 PM
oh right. it works as AS2.
I figured out it doesn't work with FlashPlayer 8 :eek:
I guess the prototype class isn't available here.

Any suggestions how to tweak the code that it works
with Player 8?