我想为我的游戏创建简单的导航。我所做的是在我的 .fla 文件和 in.as 文件的不同帧中创建空影片剪辑,将子级添加到该影片剪辑,但我收到错误Line 24 1061: Call to a possible undefined method addChild through a reference with static type班级。
这是我的 .as 文件代码:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.Event;
public class KingOfMath extends MovieClip {
public function KingOfMath():void {
//Create load progress text format
var loadProgressFormat:TextFormat = new TextFormat();
loadProgressFormat.align = "center";
loadProgressFormat.bold = true;
loadProgressFormat.font = "Arial";
loadProgressFormat.size = 16;
//Create load progress text field
var loadProgressText:TextField = new TextField();
loadProgressText.defaultTextFormat = loadProgressFormat;
loadProgressText.width = 550;
loadProgressText.x = 0;
loadProgressText.y = 350;
loadScreen.addChild(loadProgressText);
//Create progress bar mechanism
stop();
addEventListener(Event.ENTER_FRAME, loadProgress);
function loadProgress(event:Event):void {
//Get bytes loaded and bytes total
var gameBytesLoaded:int = root.loaderInfo.bytesLoaded;
var gameBytesTotal:int = root.loaderInfo.bytesTotal;
//Convert to kilobytes
var gameKilobytesLoaded:int = gameBytesLoaded / 1024;
var gameKilobytesTotal:int = gameBytesLoaded / 1024;
//Show progress text
loadProgressText.text = "Loading: " + gameKilobytesLoaded + "K/" + gameKilobytesTotal + "K";
if(gameKilobytesLoaded >= gameKilobytesTotal) {
removeEventListener(Event.ENTER_FRAME, loadProgress);
gotoAndStop(2);
}
}
}
}
}