0

Is it possible to Cast the DisplayObject into MediaElement.Am trying to add the DisplayObject into the MediaContainer, but I got the following error:

-1067: Implicit coercion of a value of type flash.display:Loader to an unrelated type org.osmf.media:MediaElement. -mediaContainer

_loader is the variable of DisplayObject.

mediaContainer.addMediaElement(_loader);

How can I rectify this problem? I am using Flash Builder4.

Mercy
  • 1,862
  • 9
  • 39
  • 75

1 Answers1

0

You can only add descendants of the MediaElement class using MediaContainer.addMediaElement(). A Loader is not related to MediaElement, so it cannot be added directly. Instead, you will need to create a MediaElement and add your Loader as a trait. This requires you to use one of the OSMF loading classes instead, and which one you choose will depend on the type of content you are loading.

shanethehat
  • 15,460
  • 11
  • 57
  • 87
  • am Trying,i got Error like This.Error:The direct addition or removal of display objects onto a MediaContainer is prohibited. at org.osmf.containers::MediaContainer/addChild() – Mercy Nov 21 '11 at 12:40
  • and also i tried to Cast Like this MediaContainer.addMediaElement(_loader as MediaElement);No Error,Nothing Displayed in the Screen – Mercy Nov 21 '11 at 12:42
  • 1
    You won't be able to cast it because they are not related classes. It seems that you need to create a MediaElement from your loaded content. – shanethehat Nov 21 '11 at 12:45
  • You can't. You need to load your content using an OSMF loader that can be used to create a MediaElement. – shanethehat Nov 21 '11 at 12:51
  • Am loading my Display Object using loader only sir – Mercy Nov 21 '11 at 13:44