1 Reply Latest reply on May 10, 2010 9:23 AM by bringrags

    Scaling/Zooming ImageElements




      this post is not only OSMF specific but it would be great if someone can help out with my problem.


      I'm currently working on a MediaPlayer which works with VideoElement and ImageElements in a series. The VideoElements are dynamic anyway so I would like to animate the static images. My goal is a "Ken Burns - Effect" with movement and zoom. But first of all I need to find a way to access the right paramters of a ImageElement to manipluate them at runtime. Because ImageElements are static I load them as DurationElements first.


      As what I know I need to access the current DisplayObject of the MediaPlayer at runtime. I do this by adding a EventListener on a ImageElement:


      imageElement1.addEventListener(MediaElementEvent.TRAIT_ADD, onTraitAdd);


      Now in the Listener function I can access the current Element:

       var displayObjectTrait:DisplayObjectTrait = event.target.getTrait(MediaTraitType.DISPLAY_OBJECT);


      But what I can't do know it to manipluate the current DisplayObject through e.g. :


       displayObjectTrait.displayObject.scaleX = 0.5;


      Working this way makes nothing happen.


      Is there a better way to manipulate the ImageElement-Parameters at runtime? Has someone an idea how to apply a dynmic zoom or scaling effect on ImageElements?

        • 1. Re: Scaling/Zooming ImageElements
          bringrags Level 4

          Have you tried using the OSMF layout API?  This might be a simpler approach since you don't have to drill down to the DisplayObject, you only need to set some layout parameters (in the form of a LayoutMetadata) object and assign it to the ImageElement.


          For an example of dynamic layout, see "Dynamic Layout" in the ExamplePlayer sample app (source here).