1 Reply Latest reply on Oct 20, 2009 11:52 PM by Flex harUI

    Loading Class from SWF File.

    thomabj2

      I have an external SWF with the MXML component called TestContent.mxml.  I want to be able to load the TestContent class into my application.

       

      I tried to do this:

       

       

      var loader:Loader = new Loader();

      var urlReq:URLRequest = new URLRequest("TestSWFProject.swf");

       

      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onloaded);

       

      loader.load(urlReq);

       

       

       

      private function onloaded(event:Event) {

                      var GUIClass:Class = event.target.applicationDomain.getDefinition("TestContent") as

                          Class;

       

                      addChild(new GUIClass());

        }

       

      I get the following error: "ReferenceError Error #1065: Variable TestContent is not defined"

       

       

      How can I load the class from the SWF into my application?