Updating code from AS2 to AS3

hello, this is my first post i really hope someone can help me :slight_smile:

i found a code on the internet that i really like it, the problem is that i am starting with flash and i find it kinda difficult to upgrade the code which is written in AS2 to AS3, i already researched and it seems that the createEmptyMovieClip method is no longer available and i need to declare the onentherframe method as well but i can’t get it done, i really hope someone can help me :slight_smile:

ah and btw i obviously didn’t make the code :slight_smile: i don’t want to claim anything and/or demerit the guy who did it

the code is :

/*
set up vars
p = number of points along the line; more = smoother curve
sx = start position of the wave
ex end of the wave
by = size of area
wl = the water level
wh = height of waves
ws = speed of wave; negative numbers make it go right
*/
for (var i = 0; i < 6; i++) {
this.createEmptyMovieClip(“wave” + i, i);
var w:MovieClip = this[“wave” + i];
w.p = 45;
w.sx = 0;
w.ex = 1024;
w.by = 1;
w.wl = 10;
w.wh = 35;
w.ws = -(0 + ((random(10) / 2) + .1) / 5000);
var Ld:String = String(i / 2);
if (Ld.length > 0) {
w.lh = 1;
} else {
w.lh = 0;
}
w.id = i;
w.sy = w.lh + w.wh + w.wl;
PI2 = Math.PI * 2;
//w._alpha = random(45) + 25;
//don’t use alpha to CPU instensive try random colors instead
w.linecolor = FFFF00
//w.linecolor = random(255) << 16 | random(255) << 8 | random(200);
w.onEnterFrame = function() {
//begin with a clean canvas
this.clear();
this.lineStyle(this.lh,this.linecolor);
for (x = 0; x < this.p; x++) {
var r:Number = x / (this.p - 1);
var px:Number = this.sx + r * (this.ex - this.sx);
var py:Number = this.sy + this.wh * Math.sin(r * r * PI2 + getTimer() * this.ws);
if (x == 0) {
this.moveTo(px, py);
}
this.lineTo(px, py);
}
};
}