开发者

Flash: Stage.FullscreenInteractive -> Difference if class or 1st frame

example 1: 1st frame of my app

    var screenBounds = Screen.mainScreen.bounds; //Bounds of current screen
    var full:Sprite = new Sprite(); //Sprite Fullscreen
    //Enter Fullscreen 
function goFullScreen(e:Event = null) {
    //myClass.goFullscreen();
    full.graphics.clear();
    full.graphics.beginFill(0xccff00);
    full.graphics.drawRect(0,0,screenBounds.width, screenBounds.height);
    full.graphics.endFill();
    addChild(full);
    this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}  

example 2: a normal as class package

    private var full:Sprite = new Sprite(); //Sprite to show fullscreen        
    private var screenBounds = Screen.mainScreen.bounds; //Bounds of current screen
public function favoritesFullscreen():void {
    full.graphics.clear();
    full.graphics.beginFill(0xccff00);
    full.graphics.drawRect(0,0,screenBounds.width, screenBounds.height);
    full.graphics.endFill();
    addChild(full);
    this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}  

So, tell me WHERE IS THE DIFFERENCE? I'm a macuser, you know, at the top the menubar and in my case the dock is aligned left

It's weird but example 1 does exactly what it should. It creates a fullscreen rectangle across the ENTIRE screen (from 0,0 to the right bottom)

However, example 2 kind of calculates the width of the top-menubar and the dock and starts the fullscreen rectangle a approx 4开发者_开发问答0px from the left edge of the screen (dock) and 20px from the top (menubar)... i don't get why a external class acts different than as on the first frame.

??? thank you for your help!


I'm guessing it has to do with when the Screen.mainScreen.bounds are retrieved. On compile time, flash internally moves all frame code within functions in the DocumentClass and calls them after the stage has completly initialized. So, in the 1st example, you are retrieving the screenBounds after everything is initializated, but in the 2nd example you are doing it much earlier.

I guess waiting for the ADDED_TO_STAGE event would be enough. If it's not, the first ENTER_FRAME event dispatched should definitely work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜