2010-10-10 121 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 
}