3 Replies Latest reply on Aug 23, 2010 6:05 AM by ScreenName1710b

    MouseEvents from an OSMF Container

    ScreenName1710b Level 1

      I have a player that contains a MediaContainer that has been added to stage.

      I'd like to be able to listen for MouseEvents when that container is clicked on; and I'd rather not have to use a fake object, or a general listener in which I have to exclude other objects.

       

      I used the mediacontainer itself, and MouseEvent.CLICK doesn't seem to be fired from it, even though the notes say it should.

      I've tried using the DisplayObject trait of my media, and that doesn't fire MouseEvents.

       

      I then took the standard straight from the MediaContainerExample implementation:

      and added a listener for the container click event.

      And nothing happens.

       

      package
      {
          import flash.display.Sprite;
          import flash.events.MouseEvent;
          
          import org.osmf.containers.MediaContainer;
          import org.osmf.elements.VideoElement;
          import org.osmf.media.MediaPlayer;
          import org.osmf.media.URLResource;

          public class MediaContainerExample extends Sprite
          {
              public function MediaContainerExample()
              {
                  super();
                 
                  // Construct a video element:
                  var resource:URLResource = new URLResource("http://mediapm.edgesuite.net/strobe/content/test/AFaerysTale_sylviaApostol_640_500_short.flv");
                  var video:VideoElement = new VideoElement(resource);
                 
                  // Construct a media container, and add it to the stage.
                  var mediaContainer:MediaContainer = new MediaContainer();
                  mediaContainer.width = 640;
                  mediaContainer.height = 500;
                  addChild(mediaContainer);
                 
                  // Add the video as a child of the media container:
                  mediaContainer.addMediaElement(video);
                 
                  
                  // Play back the video:
                  var player:MediaPlayer = new MediaPlayer();
                  player.media = video;

                  mediaContainer.addEventListener(MouseEvent.CLICK, onMediaContainerClick)
              }

               private function onMediaContainerClick(me:MouseEvent):void{
             
                     trace ("Clicked on the Video!!!");
                }
          }
      }

       

      I have not found any trait that is a subclass of InteractiveObject; so pulling from traits doesn't seem to work.

      One example I found from the forums talked about the Viewable (IViewable?) trait which I don't believe is still a part of OSMF 1.0.

       

      Is there a new solution to this issue?

      Thanks.

      -Will