Marine FishTank Attempt 1.
Code for the fish to move. © Craig Lowe – www.loweonline.co.uk
//fish movement by craig lowe www.loweonline.co.uk
// © Craig Lowe
speed=1.5; // starting speed of fish
du=0.5; //speed of the direction up and down movement
moveleft=true;
moveright=false;
moveup=false;
movedown=true;
}
onEnterFrame() {
if(dir<5){ this.moveleft=true; this.moveright=false; }if(dir>5){
this.moveright=true;
this.moveleft=false;
}
if(this.moveleft==true){
this._x=this._x-=speed;
this.moveright=false;
}
if(this.moveright==true){
this._x=this._x+=speed;
this.moveleft=false;
}
if(this.movedown==true && this._y<430){ this._y=this._y+=du; } if(this.moveup==true && this._y>30){
this._y=this._y-=du;
}
if(this._x<-30){ this._x=650; } if(this._x>650){
this._x=-30
}
}
OnEnterFrame(){
updwn=random(60);
if(this.updwn==25){
this.moveup=true;
this.movedown=false;
}
if(this.updwn==7){
this.moveup=false;
this.movedown=true;
}/*if(this.updwn>50){
this.moveup=false;
this.movedown=false;
}*/}
OnFrame(125){ // alter this (125) for quicker movement change
speed=randomRange(0,6); // speed range 0, 6 random speed from 0 to 5 pixels, o means fish will stop/ hover
dir=random(10);
if(this.dir<5 && this.moveright==true){ this._xscale *= -1; } if(this.dir>5 && this.moveleft==true){
this._xscale *= -1;
}
}
code for swishmax 2 and 3 below
onSelfEvent (load) {
//fish movement by craig lowe www.loweonline.co.uk
speed=1.5;
du=0.5;
moveleft=true;
moveright=false;
moveup=false;
movedown=true;
}
onSelfEvent (enterFrame) {
if(dir<5) {
this.moveleft=true;
this.moveright=false;
}
if(dir>5) {
this.moveright=true;
this.moveleft=false;
}
if(this.moveleft==true) {
this._x=this._x-=speed;
this.moveright=false;
}
if(this.moveright==true) {
this._x=this._x+=speed;
this.moveleft=false;
}
if(this.movedown==true && this._y<400) {
this._y=this._y+=du;
}
if(this.moveup==true && this._y>60) {
this._y=this._y-=du;
}
if(this._x<-50) {
this._x=650
}
if(this._x>650) {
this._x=-50
}
}
onSelfEvent (enterFrame) {
updwn=random(60);
if(this.updwn==5) {
this.moveup=true;
this.movedown=false;
}
if(this.updwn==3) {
this.moveup=false;
this.movedown=true;
}
/*if(this.updwn>50){
this.moveup=false;
this.movedown=false;
}*/
}
onFrame (250) {
speed=randomRange(1,3);
dir=random(10);
if(this.dir<5 && this.moveright==true) {
this._xscale *= -1;
}
if(this.dir>5 && this.moveleft==true) {
this._xscale *= -1;
}
}
Social Connect
Login with one of the following.Enter your WordPress.com blog URL
http://.wordpress.com
Proceed