0 Replies Latest reply on Sep 13, 2007 10:09 PM by Reinholdt

    Instantiating a loaded swf at runtime

    Reinholdt Level 1
      Hi

      I am trying to Instantiating a swf at runtime, what I have don is I have created a new Actionscript project in flex, and created an assets folder where I have saved a swf file called tile, the swf (tile.swf) document class is Tile, a class that extends the MovieClip class.

      In Flex I I used the following code:


      private var loader:Loader;
      private var urlRequest:URLRequest;
      private var tile:Tile;

      public function LoadAssets() {

      loader = new Loader();
      urlRequest = new URLRequest("assets/tile.swf");

      loader.contentLoaderInfo.addEventListener(Event.INIT, iniLoader);
      loader.load(urlRequest);
      }

      private function iniLoader(e:Event):void {
      tile = new Tile();

      }


      If I run it the browser crashes :-(

      If I change the iniLoader function like this:


      private function iniLoader(e:Event):void {
      addChild(loader.content);

      }


      everything is running in the browser.

      anyone knows how to get around this whit out having to cast every time that I have to reference the loaded swf?