3 Replies Latest reply on May 27, 2007 10:30 AM by kglad

    AS3 Access a Loaded SWF By Name

    vDiaz761
      Hello All,

      In AS3, when an swf is loaded via the Loader class, how do I access the loaded swf by name? Here is my code:

      stop();
      var loader:Loader = new Loader();
      var whichMovie:String = "main.swf";
      addChild(loader);

      function wakeLoadBar():void{
      loadBar.gotoAndPlay("fadeIn");
      }

      function loadTheMovie(theMovie:String):void{
      trace("LOADTHEMOVIE");
      loader.contentLoaderInfo.addEventListener(Event.OPEN, onLoaderOpen);
      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoaderProgress);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);

      loader.load(new URLRequest(theMovie));
      }

      function onLoaderOpen(event:Event):void{
      trace("OPEN");
      }

      function onLoaderProgress(event:ProgressEvent):void{
      var percent:Number = Math.floor(event.bytesLoaded / event.bytesTotal * 100) + 10;
      loadBar.gotoAndStop(percent);
      trace("Progress " + percent);
      }

      function onLoaderComplete(event:ProgressEvent):void{
      trace("Progress Complete");
      }

      wakeLoadBar();

      function loadTheMovie is called after the loader "fadesIn" and the movie begins to load.

      Let's say that after the movie loads, I want to change its x and y, how do I go about doing that?

      laodedMovieName.x = 50;
      laodedMovieName.y = 150;