3 Replies Latest reply on Nov 9, 2009 4:05 PM by Mr Binitie

    ScaleMode.SCALE does not scale a loaded swf

    Mr Binitie Level 1

      Hi There,

      This seemed possible in version 5 but no longer. I'm loading a swf and I want it to scale to the width and height of the player. The swf in this case is larger than tha player. No matter what I do the swf aspect ratio remains the same.I'll be testing to see the behaviour on other media. For the moment it SEEMS only loaded videos behave properly and load themselves at 0,0.

       

      I've also noticed that if you set the x and y values of a mediaplayersprite to 0,0 and you load in a swf the swf is not positioned at 0,0 but is centralised. This is very disconcerting and makes for positioning problems. It seems the only way is to modify the stage scaleMode and aligh properties and this will definitely impact on the general positioning of other elements on stage sespecialy where the player is integrated into a larger application. All loaded media should default to 0,0 the Flash default and then give the developer the option to centralise and position

       

      Here is the code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                      layout="absolute" width="970" height="500"
                      applicationComplete="{aggregateStuff()}">
          <dst:MediaPlayer_OSMF6 id="_mediadisplay" >
          </dst:MediaPlayer_OSMF6>
          <mx:Script>
              <![CDATA[
                  import flash.display.Sprite;
                  import flash.events.NetStatusEvent;

       

                  import org.openvideoplayer.display.*;
                  import org.openvideoplayer.events.LoadableStateChangeEvent;
                  import org.openvideoplayer.media.URLResource;
                  import org.openvideoplayer.net.NetLoadedContext;
                  import org.openvideoplayer.net.NetLoader;
                  import org.openvideoplayer.traits.ILoadable;
                  import org.openvideoplayer.traits.LoadState;
                  import org.openvideoplayer.traits.MediaTraitType;
                  import org.openvideoplayer.utils.FMSURL;
                  import org.openvideoplayer.video.VideoElement;
                  import org.openvideoplayer.composition.*;
                  import org.openvideoplayer.swf.*
                  import org.openvideoplayer.media.URLResource;
                  import org.openvideoplayer.utils.URL;
                 
              public function aggregateStuff():void
              {
                  stage.scaleMode=StageScaleMode.NO_SCALE;
                  stage.align=StageAlign.TOP_LEFT;
                 
                      var sprite:MediaPlayerSprite = new MediaPlayerSprite();
                      rawChildren.addChild(sprite);
                      //sprite.width = 800                   
                      //sprite.height=370;
                      sprite.scaleMode=ScaleMode.STRETCH;

       

                  // Create new Serial element
                  var serialElement:SerialElement=new SerialElement();
                  serialElement.addChild(new SWFElement(new SWFLoader(), new URLResource(new URL('http://largerthandisplaysprite.swf'))));
                  sprite.element=serialElement;
              }
             
              ]]>
          </mx:Script>
      </mx:Application>

        • 1. Re: ScaleMode.SCALE does not scale a loaded swf
          amosam

          I'm having a similar problem with ScaleMode. Try your code without the serialElement, just the swfElement and see if it makes a difference. I can get scaleMode working fine on an individual VideoElement, but as soon as it's wrapped in the serialElement, ScaleMode is no longer respected. I listened for the DimensionChangeEvent and see that the .newHeight property is indeed being updated but the media does not scale.

          • 2. Re: ScaleMode.SCALE does not scale a loaded swf
            Edwin van Rijkom Level 2

            Thanks for the report! I've logged this as a bug (http://bugs.adobe.com/jira/browse/FM-191).

             

            Meanwhile, the issue can be worked around by not using MediaPlayerSprite (or MediaElementSprite). Alternatively, the view can be kept separate from the control layer by using MediaPlayer, and RegionGateway like so:

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application
                 xmlns:mx          ="http://www.adobe.com/2006/mxml"
                 xmlns:media          ="org.osmf.media.*"
                 layout               ="absolute"
                 width               ="970"
                 height               ="500"
                 applicationComplete     ="onApplicationComplete()"
                 >
                 <mx:Script>
                      <![CDATA[
                           import org.osmf.media.*;
                           import org.osmf.swf.*;
                           import org.osmf.utils.*;
                           import org.osmf.composition.*;
                           import org.osmf.gateways.*;
                           import org.osmf.layout.*;
                           
                           public function onApplicationComplete():void
                           {
                                // Setup a main region:
                                var region:RegionGateway = new RegionGateway()
                                LayoutUtils.setAbsoluteLayout(region.metadata, width, height);
                                rawChildren.addChild(region);
                                
                                // Create a SWF element:
                                var swfElement:SWFElement 
                                     = new SWFElement
                                          ( new SWFLoader()
                                          , new URLResource(new URL('http://vanrijkom.org/osmf/assets/OSMF-1024x768.swf'))
                                          );
                                LayoutUtils.setRelativeLayout(swfElement.metadata, 100, 100);
                                
                                // Create new Serial element
                                var serialElement:SerialElement = new SerialElement();
                                serialElement.addChild(swfElement);
                                
                                // Direct the element to the main region:
                                serialElement.gateway = region;
                                
                                // Play the element:
                                var player:MediaPlayer = new MediaPlayer();
                                player.element = serialElement;
                           }
                      ]]>
                 </mx:Script>
            </mx:Application>
            

             

            Cheers,

            Edwin

            • 3. Re: ScaleMode.SCALE does not scale a loaded swf
              Mr Binitie Level 1

              Thanks Ed,

              I appreciate the help

              a

              Thanks for the report! I've logged this as a bug (http://bugs.adobe.com/jira/browse/FM-191).

               

              Meanwhile, the issue can be worked around by not using MediaPlayerSprite (or MediaElementSprite). Instead the view can be kept separate from the control layout by using MediaPlayer, and RegionGateway like so:

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

              <mx:Application

                   xmlns:mx      &nbsp ;   ="http://www.adobe.com/2006/mxml"

                   xmlns:media      &n bsp;   ="org.osmf.media.*"

                   layout       & nbsp;       ="absolute"

                   width       &n bsp;       ="970"

                   height       & nbsp;       ="500"

                   applicationComplete      ="onApplicationComplete()"

                   >

                   <mx:Script>

                        <![CDATA[

                           & nbsp; import org.osmf.media.*;

                           & nbsp; import org.osmf.swf.*;

                           & nbsp; import org.osmf.utils.*;

                           & nbsp; import org.osmf.composition.*;

                           & nbsp; import org.osmf.gateways.*;

                           & nbsp; import org.osmf.layout.*;

                           & nbsp;

                           & nbsp; public function onApplicationComplete():void

                           & nbsp; {

                           & nbsp;      // Setup a main region:

                           & nbsp;      var region:RegionGateway = new RegionGateway()

                           & nbsp;      LayoutUtils.setAbsoluteLayout(region.me tadata, width, height);

                           & nbsp;      rawChildren.addChild(region);

                           & nbsp;     

                           & nbsp;      // Create a SWF element:

                           & nbsp;      var swfElement:SWFElement

                           & nbsp;           = new SWFElement

                           & nbsp;            &nb sp;   ( new SWFLoader()

                           & nbsp;            &nb sp;   , new URLResource(new URL('http://vanrijkom.org/osmf/assets/OSMF-1024x768.swf'))

                           & nbsp;            &nb sp;   );

                           & nbsp;      LayoutUtils.setRelativeLayout(swfElemen t.metadata, 100, 100);

                           & nbsp;     

                           & nbsp;      // Create new Serial element

                           & nbsp;      var serialElement:SerialElement = new SerialElement();

                           & nbsp;      serialElement.addChild(swfElement);

                           & nbsp;     

                           & nbsp;      // Direct the element to the main region:

                           & nbsp;      serialElement.gateway = region;

                           & nbsp;     

                           & nbsp;      // Play the element:

                           & nbsp;      var player:MediaPlayer = new MediaPlayer();

                           & nbsp;      player.element = serialElement;

                           & nbsp; }

                        ]]>

                   </mx:Script>

              </mx:Application>

              >

               

              Cheers,

              Edwin

              >