1 Reply Latest reply on Apr 2, 2010 7:44 PM by David_F57

    Flex 4 Premium reference to the Stage issue! width and height seem to be switched??

    CannotCompute Level 1

      So I am doing a very basic resize effect with a panel, but if I want it to fill the screen, I have to switch stage.stageWidth and stage.stageHeight. I have also traced them out and they come out as switched values. Anyone else having this issue?

       

      protected function panel1_addedToStageHandler(event:Event):void

      {

            trace(stage.stageWidth, " " , stage.stageHeight);

      }

        • 1. Re: Flex 4 Premium reference to the Stage issue! width and height seem to be switched??
          David_F57 Level 5

          Hi,

           

          You maybe running into some sort of layout constraint also it depends on how you are initiating the animation, if you are doing it on startup you need to wait for creationComplete to ensure all your dimensions have been calculated for the browser. You shouldn't need to use stage dimensions either. The following code resizes a panel to fill the browser. (note using top/left/bottom/right is a lot smoother than width and height).

           

          David

           

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

             xmlns:s="library://ns.adobe.com/flex/spark"

             xmlns:mx="library://ns.adobe.com/flex/mx"

             creationComplete="application1_creationCompleteHandler(event)">

          <fx:Script>

          <![CDATA[

          import mx.events.FlexEvent;

           

          protected function application1_creationCompleteHandler(event:FlexEvent):void

          {

          pw.valueFrom=pnl.width;

          ph.valueFrom=pnl.height;

          fillscreen.play();

          }

          ]]>

          </fx:Script>

          <fx:Declarations>

          <s:Animate id="fillscreen" target="{pnl}" repeatCount="1" duration="1000">

          <s:SimpleMotionPath id="pw" property="width" valueTo="{width}"/>

          <s:SimpleMotionPath id="ph" property="height" valueTo="{height}"/>

          </s:Animate>

          </fx:Declarations>

          <s:Panel id="pnl" width="250" height="200" horizontalCenter="0" verticalCenter="0">

          </s:Panel>

          </s:Application>