开发者

as3: Error: Implicit coercion of a value of type void to an unrelated type

开发者 https://www.devze.com 2023-01-30 03:26 出处:网络
I\'m attempting to set up a Metadata object like so: public function myFunction(event:MediaFactoryEvent):void {

I'm attempting to set up a Metadata object like so:

public function myFunction(event:MediaFactoryEvent):void {

var resource:URLResource = new URLResource("http://mediapm.e开发者_开发问答dgesuite.net/osmf/content/test/logo_animated.flv");
            var media:MediaElement = factory.createMediaElement(resource);

// Add Metadata for the URLResource
var MediaParams:Object = {
  mfg:"Ford",
  year:"2008",
  model:"F150",
}

media.addMetadata("MediaParams", 
  (new Metadata()).addValue("MediaParams", MediaParams) ); 

When I attempt this, I get:

Implicit coercion of a value of type void to an unrelated type org.osmf.metadata:Metadata. (new Metadata()).addValue("MediaParams", MediaParams) ); I actually need the metadata at a couple of levels of depth there, because the metadata gets passed and another function expects the Metadata that way.

How do I get the Metadata added to my URLResource the way I want? Thanks!


The problem here is that you're trying to add the value inside the addMetadata() method. addValue() probably returns void where a Metadata object is expected.

Try this instead

var metadata:Metadata = new Metadata();
metadata.addValue("MediaParams", MediaParams);
media.addMetadata("MediaParams", metadata ); 
0

精彩评论

暂无评论...
验证码 换一张
取 消