4 Replies Latest reply on Jul 23, 2010 12:38 AM by Mykola3296

    Metadata handling in ProxyElement (inconvenient)

    Mykola3296 Level 2



      I've come across the inconvenience when working with metadata in ProxyElement.

      1) Every element that is proxied gets ProxyElement metadata values (that have been set before) on permanent basis and not loses it after being unset as a proxied element:



      public function set metadata(value:Metadata):void




      // Transfer all old values to new:


      for each (var url:String in proxiedMetadata.keys)


      value.addValue(url, proxiedMetadata.getValue(url));


      proxiedMetadata = value;

      proxiedMetadata.addEventListener(MetadataEvent.VALUE_ADD, redispatchEvent);

      proxiedMetadata.addEventListener(MetadataEvent.VALUE_CHANGE, redispatchEvent);

      proxiedMetadata.addEventListener(MetadataEvent.VALUE_REMOVE, redispatchEvent);


      2) Consumer that is listening for METADATA_ADD of ProxyElement never gets informed of new values appearing in ProxyElement metadata after the proiedElement is set. Look at this code in creating ProxyElement:


      proxy2 =

      new ProxyElement();



      function(event:MediaElementEvent):void {


      trace ("METADATA ADDED: " + event.namespaceURL);




      function(event:MediaElementEvent):void {


      trace ("METADATA REMOVED: " + event.namespaceURL);




      And this, say, button click handler:



      var e:MediaElement = new MediaElement();


      if (null == proxy2.getMetadata("META1")) {


      "META1", new Metadata());


      else {


      "META2", new Metadata());


      proxy2.proxiedElement = e;




      METADATA_ADD and METADATA_REMOVED are never called.


      This is particulary inconvenied when using LoadFromDocumentElement. Imagine complex processing of loaded content with adding metadata to it - top level LoadFromDocument will never inform a listener of the addition of proxied metadata when its content is loaded and formed.


      For now I'm using a temporary solution like this:



      override public function set proxiedElement(value:MediaElement):void {


           super.proxiedElement = value;



           if (null == value) return;



           //Copy all proxied metadata


           var keys:Vector.<String> = value.metadataNamespaceURLs;


           for each (var key:String in keys) {

                addMetadata(key, value.getMetadata(key));




      It does not fire METADATA_REMOVE events but OK for LoadFromDocuments.


      I think it will be great if ProxyMetadata gets somehow rewritten in later releases - or may be I'm not getting a concept of ProxyElement?

      What do you think?


      Thank you!