5 Replies Latest reply on Aug 21, 2008 5:26 PM by justria

    How to correctly resize a component after loading using SWFLoader

    justria Level 1
      In an app, I load SWFs into an AIR app, which manages them. The AIR app loads the SWF, then creates a 'master' component, which manages the loaded SWF. 'manages' means resize, move or provide persisted preference values.

      My own test Flex SWFs work OK, while another SWF does not. Here's a screenhot:

      http://www.flexolero.com/demos/Portal/shot.png

      Note, that only some part of the loaded Clock resized correctly.

      The actual resize is done like this:

      quote:

      public function resize( newW:int, newH:int ):void {

      var loadedSM:SystemManager = SystemManager( ( _inner as SWFLoader ).content );

      if ( ( null != _inner )
      && ( null != loadedSM )
      && ( null != loadedSM.application )
      ) {
      // BindingUtils.bindProperty( lblFromRemote, "text", loadedSM.application, '_outChannel' );
      // loadedSM.application[ 'inChannel' ] = 'New';
      loadedSM.application[ 'width' ] = newW-20;
      loadedSM.application[ 'height' ] = newH-20;
      this.width = newW;
      this.height = newH;
      _inner.invalidateSize();

      drawHandles();
      }

      }



      If the Air app finishes loading the SWF, the master component attaches a method to the managed SWF:

      (_inner as UIComponent).addEventListener( Event.RENDER, fixSizes );

      Actually, Clock sample does not resize as expected at the first time it appears.

      Once the Clock is on stage, and I resize it using the mouse, it resized as expected.

      Could someone provide a hint?





        • 1. Re: How to correctly resize a component after loading using SWFLoader
          Level 7
          maybe you need to calculate scaleX, scaleY instead?

          "justria" <webforumsuser@macromedia.com> wrote in message
          news:g8fbml$e7c$1@forums.macromedia.com...
          > In an app, I load SWFs into an AIR app, which manages them. The AIR app
          > loads
          > the SWF, then creates a 'master' component, which manages the loaded SWF.
          > 'manages' means resize, move or provide persisted preference values.
          >
          > My own test Flex SWFs work OK, while another SWF does not. Here's a
          > screenhot:
          >
          > http://www.flexolero.com/demos/Portal/shot.png
          >
          > Note, that only some part of the loaded Clock resized correctly.
          >
          > The actual resize is done like this:
          >
          >
          quote:

          public function resize( newW:int, newH:int ):void {
          >
          > var loadedSM:SystemManager = SystemManager( ( _inner as SWFLoader
          > ).content );
          >
          > if ( ( null != _inner )
          > && ( null != loadedSM )
          > && ( null != loadedSM.application )
          > ) {
          > // BindingUtils.bindProperty( lblFromRemote, "text",
          > loadedSM.application, '_outChannel' );
          > // loadedSM.application[ 'inChannel' ] = 'New';
          > loadedSM.application[ 'width' ] = newW-20;
          > loadedSM.application[ 'height' ] = newH-20;
          > this.width = newW;
          > this.height = newH;
          > _inner.invalidateSize();
          >
          > drawHandles();
          > }
          >
          > }
          >

          >
          > If the Air app finishes loading the SWF, the master component attaches a
          > method to the managed SWF:
          >
          > (_inner as UIComponent).addEventListener( Event.RENDER, fixSizes );
          >
          > Actually, Clock sample does not resize as expected at the first time it
          > appears.
          >
          > Once the Clock is on stage, and I resize it using the mouse, it resized as
          > expected.
          >
          > Could someone provide a hint?
          >
          >
          >
          >
          >
          >
          >


          • 2. Re: How to correctly resize a component after loading using SWFLoader
            justria Level 1
            quote:

            Originally posted by: Newsgroup User
            maybe you need to calculate scaleX, scaleY instead?



            Hm, no, I don't think that this is an option, since I don't want to scale the loaded SWF. I want to resize it, since the component then can decide on its own how to adopt the new size.

            • 3. Re: How to correctly resize a component after loading using SWFLoader
              Level 7

              "justria" <webforumsuser@macromedia.com> wrote in message
              news:g8hiim$l1k$1@forums.macromedia.com...
              >
              quote:

              Originally posted by: Newsgroup User
              > maybe you need to calculate scaleX, scaleY instead?
              >

              >
              > Hm, no, I don't think that this is an option, since I don't want to scale
              > the
              > loaded SWF. I want to resize it, since the component then can decide on
              > its own
              > how to adopt the new size.

              Sounds like you just have to live with whatever decisions it makes, then ;-)


              • 4. Re: How to correctly resize a component after loading using SWFLoader
                justria Level 1
                That might be true, Amy.

                As a last resort, I might use a Timer to fire once, when typically components finish rendering.

                Hm, bad design...
                • 5. Re: How to correctly resize a component after loading using SWFLoader
                  justria Level 1
                  Actually, the Timer did the trick. But obviously, it is an ugly one :-(