1

すべてのタイムラインでどこでも実行される関数をどうにかして作成できますか?

60 秒ごとに実行されるのはどれですか?

4

3 に答える 3

2

使用flash.utils.setInterval機能:

setInterval(functionToCall , 60000 );
于 2012-09-28T05:53:04.837 に答える
1

60 秒ごとに関数を実行し、その関数がプロジェクトのどこからでも呼び出されるたびに追跡したいということですか?

このために、プロジェクトのルート (MainTimeline など) からイベントをディスパッチするだけです。

var timer:Timer = new Timer(60000);

timer.start();
timer.addEventListener(TimerEvent.TIMER, handleMinuteElapsed);

function handleMinuteElapsed(e:TimerEvent):void
{
    // Create and dispatch a custom event.
    // You should consider extending the Event class and using your Event instead,
    // this is primarily for demonstration and ease of implementation.
    var event:Event = new Event("MinuteElapsed");
    dispatchEvent(event);
}

これで、プロジェクトの任意のタイムラインのどこからでも、これを使用できます。

root.addEventListener("MinuteElapsed", handler);

function handler(e:Event):void
{
    // Do something in response to the event being triggered.
    //
}
于 2012-09-28T01:20:29.213 に答える
0

ルート シーンに移動し、新しいレイヤーを作成して関数を追加します。MovieClip(root).functionName(); を使用してどこからでも呼び出します。

于 2012-09-28T01:07:28.397 に答える