Incrue

02-16-2006, 09:58 AM

So, how this code would be in AS3???

Please help me to understand, i can only understand with examples...

origin = new Object();

origin.x = 150;

origin.y = 150;

focalLength = 300;

figureA.x = -50;

figureA.y = 0;

figureA.z = 0;

figureA.dir = 1;

figureB.x = 0;

figureB.y = 0;

figureB.z = 250;

figureB.dir = 1;

figureC.x = 50;

figureC.y = 0;

figureC.z = 500;

figureC.dir = 1;

speed = 20;

backAndForth = function(){

this.z += speed*this.dir;

if (this.z > 500){

this.z = 500;

this.dir = -1;

}else if (this.z < 0){

this.z = 0;

this.dir = 1;

}

var scaleRatio = focalLength/(focalLength + this.z);

this._x = origin.x + this.x * scaleRatio;

this._y = origin.y + this.y * scaleRatio;

this._xscale = this._yscale = 100 * scaleRatio;

this.swapDepths(-this.z);

};

figureA.onEnterFrame = backAndForth;

figureB.onEnterFrame = backAndForth;

figureC.onEnterFrame = backAndForth;

Please help me to understand, i can only understand with examples...

origin = new Object();

origin.x = 150;

origin.y = 150;

focalLength = 300;

figureA.x = -50;

figureA.y = 0;

figureA.z = 0;

figureA.dir = 1;

figureB.x = 0;

figureB.y = 0;

figureB.z = 250;

figureB.dir = 1;

figureC.x = 50;

figureC.y = 0;

figureC.z = 500;

figureC.dir = 1;

speed = 20;

backAndForth = function(){

this.z += speed*this.dir;

if (this.z > 500){

this.z = 500;

this.dir = -1;

}else if (this.z < 0){

this.z = 0;

this.dir = 1;

}

var scaleRatio = focalLength/(focalLength + this.z);

this._x = origin.x + this.x * scaleRatio;

this._y = origin.y + this.y * scaleRatio;

this._xscale = this._yscale = 100 * scaleRatio;

this.swapDepths(-this.z);

};

figureA.onEnterFrame = backAndForth;

figureB.onEnterFrame = backAndForth;

figureC.onEnterFrame = backAndForth;