2010-10-10 123 views
-1

我试图让投影仪文件在启动时运行全屏,而无需单击任何内容。我的主要类从MovieClip的继承,所以据我可以告诉我可以访问舞台...是吧:)在AS3中访问舞台

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.我确信我已经进入舞台,我真的很困惑。

回答

4

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

请尝试以小写字母访问它。另外,如果您访问构造函数中的舞台,它将不会被分配。

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 
}