4 Replies Latest reply on Sep 26, 2010 7:25 AM by kfirufk

    loading library.swf (unpacked from swc) using loader() and using it's assets

    kfirufk Level 1
      I try to load libary.swf from an swc file in order to use it's library items.
      i load the library.swf using urlrequest and loader() and then use getDefinition() to fetch the class definition
      of the UIMovieclip element.

      i simply created the swc file by adding library assets to an swf file, converting them to a flex component and extending each compoent with the UIMovieClip class.

      when i load the swf file from a url (http) i get the following error:
      VerifyError: Error #1053: Illegal override of UIMovieClip in mx.flash.UIMovieClip.

       

      when i load the file locally, i get no error. any ideas why?

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">

       

          <fx:Script>
              <![CDATA[
                  import mx.core.UIComponent;
                  import mx.flash.UIMovieClip;
                 
                  private var _context: LoaderContext;
                  private var _request: URLRequest;
                  private var _loader:Loader;
                  private var _library:Object;
                  private var _executeFunction:Function = null;
                 
                  public function _setExecuteFunction(f:Function):void {
                      this._executeFunction=f;
                  }
                 
                  public function handleLibInitialized(e:Event):void {
                      this._library=e.target.applicationDomain;
                      var a:Class = this._library.getDefinition("lobby_page_component");
                      var b:MovieClip = new a() as MovieClip;
                     
                      var c:UIComponent = new UIComponent();
                      c.addChild(b);
                      this.addElement(c);
                  }       
                 
                  public function init():void {
                      Security.allowDomain("*");
                      var url2:String="http://url/for/library.swf"; <- http provides an error
                       var url2:String="/path/to/library.swf"; <- local path works
                                   this._context = new LoaderContext(false,ApplicationDomain.currentDomain);
                      this._request = new URLRequest(url2);
                      this._loader = new Loader();
                      this._loader.contentLoaderInfo.addEventListener(Event.INIT,this.handleLibInitialized);
                      this._loader.load(this._request,this._context);
                         
                  }
                 
              ]]>
          </fx:Script>

       

      </s:Application>