読み込み画面を Flash で動作させようとしています。これが私のプロジェクトのセットアップ方法です。
すべてのゲームは、「レベル 0」、「レベル 1」などのさまざまなシーンに設定された「レイヤー 1」で発生します。そのコードは「.as」ファイルで実行されます。
新しいレイヤー「プリローダー」にシンプルなロード画面(プログレスバー付き)を実装してみました。そのコードは、レイヤーの「アクション」で実行されます。
最初にレイヤー 1 の「.as」ファイルをレベル 0 でロードしたため、プリローダーのコードを「アクション」に配置することは最善のアイデアではなかったことがわかりました。そのため、「プリローダー」レイヤーと「レイヤー 1」レイヤーは同時に実行しようとしました。これにより問題が発生しました。
今、プリローダーを独自のシーンに入れてみました。それは機能していません。
プリローダーに使用しようとしたコードは次のとおりです-「シーン」バージョン:
// This function loads the Preloader
public function loadPL(event:Event) {
// Load the Scene associated with the Preloader
this.gotoAndStop(1, "PL");
// Prevent the MovieClip (game) from playing right away
stop();
// Add an EventListener that calls the 'loading()' function
this.addEventListener(Event.ENTER_FRAME, loadingPL);
} // End of 'loadPL()' method
// 'loading()' function
// This function calculates how much of the game has been loaded vs. how much data
// the game contains. The loading progress bar is resized accordingly.
public function loadingPL(e:Event):void{
// How much data does the game have in all?
var totalData:Number = this.stage.loaderInfo.bytesTotal;
// How much data has been loaded so far?
var loadedData:Number = this.stage.loaderInfo.bytesLoaded;
// Scale the 'plBarIns' according to the loadedData:totalData ratio
plBarIns.scaleX = loadedData/totalData;
// If the 'loadedData' == 'totalData' (all of the game's data has been loaded), allow
// the game to play
if (loadedData == totalData) {
play();
// Remove the EventListener that calls the 'loading()' function. It's not needed now
this.removeEventListener(Event.ENTER_FRAME, loadingPL);
}
}
誰でも私を助けることができますか?
ありがとう、クリスチャン