我是 AS3 和课程的新手。我需要一些帮助来将预加载器链接到其他类。因此,如果 main_class 触发函数 show_titleScene,预加载器将显示并在播放前加载数据。我尝试了很多但没有结果。我不知道如何链接。
coreEngine = main_class
public class coreEngine extends MovieClip
{
public var loading_screen:loading_scene;
public var splash_screen:splash_scene;
public var warning_screen:warning_scene;
public var title_screen:title_scene;
public var game_screen:game_scene;
public function coreEngine() {
show_loadingScene();
}
public function show_loadingScene() {
loading_screen = new loading_scene();
addChild(loading_screen);
}
public function show_splashScene() {
splash_screen = new splash_scene();
addChild(splash_screen);
}
public function show_gameScene() {
game_screen = new game_scene();
addChild(game_screen);
}
}
loadingScene = 预加载器类
public class loading_scene extends MovieClip
{
public var core:coreEngine;
public function loading_scene()
{
this.addEventListener(Event.ENTER_FRAME, loading);
}
function loading(e:Event):void{
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
loadingBar.loadingFill.scaleX = loaded / total;
loader_txt.text = Math.floor((loaded / total) * 100) + "%";
if (total == loaded){
trace("LOADIN");
this.removeEventListener(Event.ENTER_FRAME, loading);
core.show_splashScene();
}
}
}