1 Reply Latest reply on Mar 19, 2011 10:15 AM by simonwidjaja

    urgent: Passing Metadata to SWF loaded via SWFElement?

    simonwidjaja

      Hi!

      my problem: I have a SWF-Animation made in Flash. This animation will be loaded via a OSMF-Plugin as an overlay (SWFElement in ParallelElement). That works perfectly so far. But now I have to pass some Text (Metadata) to the SWF. Passing the metadata to the plug in works. But how does the plugin inject the metadata into the SWF or how do I access the metadata within the SWF?

       

      Any ideas?

       

      Thanks in advance,

      Simon

        • 1. Re: urgent: Passing Metadata to SWF loaded via SWFElement?
          simonwidjaja Level 1

          Since the forums were down I played around on my own. I came up with the following solution.

          I'm not sure if there are better ways that are more straight forward (e.g. with metadata etc.) but it works fine so far.

           

              override public function set proxiedElement(value:MediaElement):void {
                log( "proxiedElement was set" );
                
                var overlayResource:URLResource = new URLResource( OVERLAY_URL );
                var overlayElement:SWFElement = new SWFElement( overlayResource );
                
                overlayElement.addEventListener( MediaElementEvent.TRAIT_ADD, 
                  function(e:MediaElementEvent):void {
                    if ( e.traitType == "displayObject" ) {
                      var el:SWFElement = e.currentTarget as SWFElement;
                      var dot:DisplayObjectTrait = DisplayObjectTrait( el.getTrait( MediaTraitType.DISPLAY_OBJECT ) );
                      var loader:Loader = Loader( dot.displayObject );
                      if ( loader.content.hasOwnProperty( "setMetadata" ) ) {
                        Object( loader.content ).setMetadata( 
                          { title: "Grant Skinner", details: "FITC 2011 - Amsterdam" }
                        );
                      }
                    }
                  }
                );
          
                
                var layout:LayoutMetadata = new LayoutMetadata();
                layout.width = 520;
                layout.height = 100;
                layout.bottom = layout.left = 0;
                layout.index = 999;
                overlayElement.addMetadata( LayoutMetadata.LAYOUT_NAMESPACE, layout );
                
                var durationElement:DurationElement = new DurationElement( 5, overlayElement );
                
                var parallel:ParallelElement = new ParallelElement();
                parallel.addChild( durationElement );
                parallel.addChild( value );
                super.proxiedElement = parallel;
              }