すべてのタイムラインでどこでも実行される関数をどうにかして作成できますか?
60 秒ごとに実行されるのはどれですか?
setInterval(functionToCall , 60000 );
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.
//
}
ルート シーンに移動し、新しいレイヤーを作成して関数を追加します。MovieClip(root).functionName(); を使用してどこからでも呼び出します。