-2
我一直在努力嘗試將我在AS2中創建的這個非常棒的代碼轉換爲AS3,我知道它一定很簡單,但我對AS3不太瞭解。請幫助AS2到AS3代碼轉換
reference = 240;
MovieClip.prototype.asNewStar = function()
{
this.x = random(Stage.width)-Stage.width/2;
this.y = random(Stage.height)-Stage.height/2;
this.z = 1000;
this.onEnterFrame = function()
{
if ((this.z -= 20) < -100) this.removeMovieClip();
else this.drawStar();
}
}
MovieClip.prototype.drawStar = function()
{
this.clear();
this.lineStyle(10-this.z/200, Math.random() * 0xFFFFFF, 100);
perspectiveRatio = reference/(reference + this.z);
this.moveTo(this.x*perspectiveRatio, this.y*perspectiveRatio);
perspectiveRatio = reference/(reference + this.z + 40);
this.lineTo(this.x*perspectiveRatio, this.y*perspectiveRatio);
}
this.createEmptyMovieClip("galaxy",1);
galaxy._x = Stage.width/2;
galaxy._y = Stage.height/2;
galaxy.onEnterFrame = function()
{
this.createEmptyMovieClip("star"+ ++depth, depth).asNewStar();
}
您好!你顯然是新的,所以沒關係,但這不是爲你轉換代碼的地方。請[閱讀常見問題](http://stackoverflow.com/help/on-topic)瞭解您可以在本網站上詢問的問題類型。 – Marty