开发者

Maximizing AIR WindowedApplication and resizing containg component

开发者 https://www.devze.com 2023-04-02 00:52 出处:网络
I am trying to create an AIR app that you can maximize, and when you maximize all the components contained in the windo开发者_开发知识库wedApplication are scaled with the containing windowedApplicatio

I am trying to create an AIR app that you can maximize, and when you maximize all the components contained in the windo开发者_开发知识库wedApplication are scaled with the containing windowedApplication.

At the moment when you maximize the window all the components just stay the same size. Is this even possible?

<?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>


You can listen for the resize event dispatched by any UIComponent :

<?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>

Be careful, though, because this kind of trick may cause infinite loop : you listen for a resize event, then resize a component that causes another resizeevent to be dispatched, and the loop goes back from the start...

0

精彩评论

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