最大化AIR Windows应用程序并调整包含组件的大小

时间:2011-09-03 18:58:29

标签: flex air flex-spark

我正在尝试创建一个可以最大化的AIR应用,当您最大化windowedApplication中包含的所有组件时,将使用包含windowedApplication进行缩放。

当您最大化窗口时,所有组件都保持相同的大小。这甚至可能吗?

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:ATE="http://ns.adobe.com/ate/2009"
                       xmlns:ai="http://ns.adobe.com/ai/2009"
                       xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"
                       xmlns:d="http://ns.adobe.com/fxg/2008/dt"
                       xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       xmlns:lib="assets.graphics.UI.*"
                       xmlns:flm="http://ns.adobe.com/flame/2008"
                       xmlns:lib2="assets.graphics.*"
                       xmlns:components="components.*"
                       xmlns:lib3="assets.graphics.logout.*"
                       xmlns:lib4="assets.graphics.logo.*"
                       xmlns:sparkTree="com.sparkTree.*"
                       xmlns:testsubmitassessmentscore2="services.testsubmitassessmentscore2.*"
                       minWidth="800" minHeight="600" backgroundColor="#FFFFFF"
                       creationComplete="creationCompleteHandler()" showStatusBar="false"
                       currentState="{model.whichViewState}" currentStateChange="onStateChange()"
                       preloaderChromeColor="#FFFFFF" title="MyApplication">
    <!--<fx:Style source="Main.css">-->
    <!--minWidth="800" minHeight="600"-->
    <fx:Style>

1 个答案:

答案 0 :(得分:0)

您可以侦听任何UIComponent调度的resize事件:

<?xml version="1.0" encoding="utf-8"?>
<s:Group
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    width="100%" height="100%"
    resize="onResize(event)"
    >
    <fx:Script>
        <![CDATA[
        import mx.events.ResizeEvent;

        private function onResize(event:ResizeEvent):void
        {
            // code goes here : resize your components and stuff...
        }
        ]]>
    </fx:Script>
</s:Group>

但是要小心,因为这种技巧可能导致无限循环:你监听一个resize事件,然后调整一个组件,调整导致另一个resizeevent被调度,并且循环从一开始就回来......