如何为页面使用多个框架

时间:2013-06-24 11:11:16

标签: actionscript-3 flash flex actionscript

我想为我的游戏创建简单的导航。我所做的是在我的.fla文件和in.as文件中创建空的影片剪辑将子项添加到该影片剪辑,但是我收到错误第24行1061:通过引用调用可能未定义的方法addChild使用静态类型。

这是我的.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);
            }

        }
    }
}
}

0 个答案:

没有答案