views:

205

answers:

1

hello, i don't get it!

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 40px 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!

A: 

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.

Cay
Thank you, however i've no idea how //Bounds of current screen private function setScreen() { setTimeout(function(){ screenBounds = Screen.mainScreen.bounds; },5000);<\br> }
could it be the stage.align property then? it should be set to "TL" at the beginning of your application...
Cay
SOLVED IT! thank you!