简体   繁体   中英

Adobe Air Desktop App Constrain window size

I have an Adobe Air app that runs on Mac and PC. (coded in AS3) However, the app has the dimensions of 540 by 960. I have content hidden off the visible stage however if the user resizes the window my content to the side shows and looks really funny.

Is there a way to block the user from resizing the app window container?

I know I can remove the window but then they can't drag the app across screen or minimize it if they want. THERE HAS.. to be an easy way to block them from resizing.

Thanks for the tips.

I Found the answer. :)

<application....>
    <!-- Normal app stuff like id, name, etc -->
    <initialWindow>
        <!-- Normal initialWindow stuff like content, title, systemChrome -->
        <minimizable>true</minimizable>
        <maximizable>false</maximizable>
        <resizable>false</resizable>
        <width>800</width>
        <height>600</height>
    </initialWindow>
</application>

Answer found here: In AIR, how do you create a windowed application that's not resizable?

You can actually leave the window resizable and set the max size for the window. This allows your user to resize it to be smaller than your content etc.

... 
<initialWindow>
    <minimizable>true</minimizable>
    <maximizable>false</maximizable>
    <resizable>true</resizable>
    <width>800</width>
    <height>600</height>

    <maxSize>800 600</maxSize>

    ...
</initialWindow>

See here for more information on the elements: http://help.adobe.com/en_US/air/build/WSfffb011ac560372f2fea1812938a6e463-8000.html#WSfffb011ac560372f2fea1812938a6e463-7fe7

To change the dimensions of the window programmatically you need to use the NativeWindow reference from the stage:

import flash.display.NativeWindow;

// Simple validity check
if (stage && stage.nativeWindow)
{
    stage.nativeWindow.width = SOME_WIDTH;
    stage.nativeWindow.height = SOME_HEIGHT;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM