-2

AS2 で作成したこの素晴らしいコードを AS3 に変換しようとして失敗しました。かなり単純に違いないことはわかっていますが、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();
}
4

1 に答える 1