1 Reply Latest reply on Jul 3, 2006 8:21 AM by Rothrock

    Loading external .swf file questions

    gregmax17 Level 1
      Is there a way to _xscale and _yscale external .swf after loading them?

      Is there a way to 'talk' to the external .swf file after loading and placing it on the stage? By this I mean: will I be able to send variables/commands/functions back and forth from the playing movie and the external .swf file?

      Also, if it isn't too much to ask, can you please give an example with AS?

      Thank you
        • 1. Re: Loading external .swf file questions
          Rothrock Level 5


          It is too much.


          Have you tried anything? Isn't it working for you? If not, you have actually stumbled upon the answer in your post without realizing it. The trick is that you wait until the external swf file has completely loaded before you try and do any "talking."

          If your external swf is loaded into myHolder_mc then the following code will work – ONLY after the external file has completed its loading:


          Or whatever. It is exactly like referencing any movieclip or setting any variable/property.

          So the trick becomes knowing when your external file has completed loading. This is what is known as preloading and if you check the forums or google "actionscript preload" you should find many, many, many hits.

          If you are using Flash MX04 or greater I recommend the MovieClipLoader class. It provides nice events that tell you when the clip has loaded (use onLoadInit). You can find sample code in the help files.

          If you will be publishing for early versions of Flash then you will have to make an old-school preloader. That will require using the getBytesLoaded and getBytesTotal methods of the MovieClip class. Something like this:

          var bt=myHolder_mc.getBytesTotal();
          var bl=myHolder_mc.getBytesLoaded();
          if (bt==bl && myHolder_mc._width>0){
          delete this.onEnterFrame
          //external asset is loaded so do whatever you want

          That is the most basic, but it can expand and go in a lot of ways.