2 Replies Latest reply on Oct 25, 2006 11:46 AM by pinos

    Access an instance from a loaded SWF.

    pinos
      Hi all,

      I have a Flash movie and within that movie I want to load an external SWF file (intro.swf)

      This is the code that I use in frame 1:

      var mclListener:Object = new Object();
      mclListener.onLoadStart = function(target_mc:MovieClip) {
      // empty
      };
      mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
      infoField_txt.text = Math.round(bytesLoaded/bytesTotal*100);
      };
      mclListener.onLoadComplete = function(target_mc:MovieClip) {
      movieLoader_mc.object_mc._x = 200;
      };
      mclListener.onLoadInit = function(target_mc:MovieClip) {
      // empty
      };

      var image_mcl:MovieClipLoader = new MovieClipLoader();
      image_mcl.addListener(mclListener);
      image_mcl.loadClip("intro.swf", movieLoader_mc);

      stop();

      The loading of the movie is working fine. BUT the question is.. how do I access the instance object_mc in intro.swf from my main movie?

      I tried a lot of things like _root.movieLoader_mc.object_mc but it isn't working :(

      Thanks in advance.
        • 1. Re: Access an instance from a loaded SWF.
          S4Potential
          The problem is the complete event is dispatched when the movie is loaded but before the elements of first frame in the loaded movie are available.

          You should use the MovieClipLoader class and use its onLoadInit event which is dispatched when after the first frame of the loaded movie is executed.

          If you used the Loader component because you wanted to use the ProgressBar component whit it, you can still associate the ProgressBar source to the movieclip use to load the swf but don't forget to change the ProgressBar mode to polled as it is described in the ProgressBar component help.
          • 2. Re: Access an instance from a loaded SWF.
            pinos Level 1
            S4Potential,

            It works now :)

            I thought the onLoadInit event initializes the loading of the movie.. I was wrong..

            THANKS!