0

Flash Pro CS6 でビルドされた塗り絵アプリがあります。次のコードを使用して、色付けする図形を「coloringBook」というオブジェクトに追加します。

for (var i = 0; i <= colorable.totalFrames; i ++) {
    shape = new (getDefinitionByName(pattern) as Class)();
    shape.gotoAndStop(i + 1);
    coloringBook.addChild(shape);
    shape.x = Math.abs(gWidth - dWidth)/2;
    shape.y = Math.abs(gHeight - dHeight)/2;
    if (i < colorable.totalFrames) {shape.addEventListener(MouseEvent.CLICK, colorColorable);}
}

コードは非常にうまく機能しますが、ステージに追加される各形状をユーザーに表示することで、アプリに洗練を加えたいと考えていました。コードに一時停止 (スリープ タイマーなど) を追加することはできますが、すべてのタイマーが完了するまでアプリが空白になり、図形のコンパイルが完了したことを示します。コーディングに関するガイダンスをいただければ幸いです。

4

1 に答える 1

0

enter_frame を使用して、フレームごとに 1 つのシェイプを作成してみることができます。多分このようなもの:

var currentIndex:int = 0;

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

private function enterFrameHandler(e:Event):void 
{
    shape = new (getDefinitionByName(pattern) as Class)();
    shape.gotoAndStop(currentIndex + 1);
    coloringBook.addChild(shape);
    shape.x = Math.abs(gWidth - dWidth)/2;
    shape.y = Math.abs(gHeight - dHeight)/2;
    if (currentIndex < colorable.totalFrames) 
    {
        shape.addEventListener(MouseEvent.CLICK, colorColorable);
    }
    else 
    {
        stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
    }

    currentIndex++;
}
于 2013-09-30T01:40:48.277 に答える