访问AS3中的舞台

时间:2010-10-10 18:07:15

标签: flash actionscript-3 stage

我正在尝试让投影机文件在启动时全屏运行,而无需点击任何内容。我的主要类继承自MovieClip,所以据我所知,我可以访问舞台...是的,是的:)

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.display.StageDisplayState;
    import flash.display.Stage;
    import flash.ui.Mouse;


    public class PhoneDemo extends MovieClip
    {
        Stage.displayState=StageDisplayState.FULL_SCREEN;
        //declare variables
        public var scoreArray:Array = [null];

这根本不起作用,我无法进入舞台,我得到错误1120.我确信我之前已经进入舞台,我真的很困惑。

2 个答案:

答案 0 :(得分:4)

stage是DisplayObject的属性; Stage是班级。

尝试以小写形式访问它。此外,如果您在构造函数中访问该阶段,它将不会被分配。

答案 1 :(得分:3)

public class PhoneDemo extends MovieClip{
   addEventListener(Event.ADDED_TO_STAGE, addedToStage);
   // you cannot access the stage here, because the stage relation has not been established
}

internal function addedToStage(e:Event){
    removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
    // you  can access the stage here
}