2
\$\begingroup\$

I have an issue with developing an Air desktop app using FlashDevelop in ActionScript 3.0

I'm pretty much new to all this, but I think I made all I should and am wondering if this could be some bug outside my code.

My screen and desktop composition is as follows:

1x Surface pro 3 with Multitouch 2160x1440 screen on the left (Identified as Screen 1) 1x Dell P2314T Multitouch with 1920x1080 screen in the middle (Identified as Screen 2) 1x Dell P2314T Multitouch with 1920x1080 screen on the right (Identified as Screen 3)

When I run Air app with fullscreen mode with

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;

I get it on the Surface's screen on fullscreen, it being the windows Main display. If I trace the stage.nativeWindow.width and stage.nativeWindow.height I get the correct resolution.

Now since I wanted the app to run on the 23" screen, I set Screen 2 to be the Main display in windows. Now AIR app is ran on the screen 2 by default, thus reporting the stage width and height being 1920 and 1080. However, the child sprites I have on stage with coordinate x = 0 are outside my screen area! They are not visible on the screen on the left, but simply hidden like they're outside of the stage. If I put first child x offset to 120 (half of the difference between 1920 and 2160 screen widths), it's positioned approx on the left edge.

To see better what's going on, I went to screen resolution manager and disabled the internal Surface's screen completely ("Don't show desktop on this screen", thus leaving me with 2x 1920x1080 screens only.

If I run the code now, the stage.nativeWindow.width and height are reporting resolution of 2160x1440 - that's screen 1, which is disabled and has no image on it at all. The Sprite x offset issue remains the same, being 120 in minus.

The code is completely clear, having stage with single sprite and quad drawn.

public class Main extends Sprite 
    {

        static public var instance:Main;

        public function Main() 
        {
            instance = this;
            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
            stage.displayState = StageDisplayState.FULL_SCREEN;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.nativeWindow.alwaysInFront = true;


            trace( String(stage.nativeWindow.x) + ' y: ' +
            String(stage.nativeWindow.y) + ' size h: ' +
            String(stage.nativeWindow.height) + ' w: ' +
            String(stage.nativeWindow.width) );
            init()      
        }   

        private function init():void
        {
            frame = new Sprite
            frame.x = 120;
            frame.y = 450;
            addChild(frame);    
            trace('frame x: ' + frame.x);

        }

    }

What could possibly cause such error? Could someone confirm whether this error is reproducible?

Thanks!

Edit 1:

Ok, seems like the failed offset was fixed adding the stage align property in main:

stage.align = StageAlign.TOP_LEFT 

I'm still interested to know why the runtime default align happens using scree 1 instead of main's resolution, and therefore fails to be correct though!

The magic about wrong resolution still stays the same, and can't be reproduced using two different screens (AOC 1920x1080 and Dell 1920x1200) in same composition, using same settings. Weird...

\$\endgroup\$
1
\$\begingroup\$

In order to listen to stage resize, orintation change, and to position items correctly on your screen, the only option is: Stage.align = StageAlign.TOP_LEFT; Stage.scaleMode = StageScaleMode.NO_SCALE; Then, you resize and layout items yourself.

If you use other alignments (TOP, TOP_RIGHT, BOTTOM, BOTTOM_RIGHT, BOTTOM_LEFT) stage will not report that it has been moved, and even if you see it centered, it doesnt tell you. 0.0 in that case will be relativo to top left corner of ALIGNED stage, but nothing will warn you.

So, NO_SCALE, TOP_LEFT are the winning combination for AIR apps.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.