2 Replies Latest reply on May 21, 2007 11:03 AM by buabco

    SWFloader embeded content

    Gregor Rot
      Hi, i would like to load the same swf into two different SWFloader components, but i don't want the content to be transfered 2 times, just once (due to bandwidth).

      No idea how to do that (embed a swf after run-time) and then assign it to a SWFloader - anyone?

        • 1. Re: SWFloader embeded content
          i have ask this question before, but nobody answer :'(

          i try several way, and i found:
          just load twice, but don't load at once,
          load the second only when the first load are complete,
          then Flash Player will load from browser cache,
          so it only request from server only once.

          (but i have not sure will this going this way every times or not)
          • 2. Re: SWFloader embeded content
            buabco Level 1
            OK is it possible to clone an object with all its contents, so you can do what you want with out loading the stuff two times.

            I found this trick somewhere on the internet, and I posted it in somewhere in this forum (Couldn't find it), so here it goes again :), I don't remember the author ether (Sorry) to clone a loaded object you go like this:

            the original SWF that you loaded should be stored in the f variable for this to work it should be a MovieClip not the SWFLoader itself but the content, it might work with the SWFLoader though but I haven't try it so can't say.

            var mc_class:Class = f["constructor"];
            var new_mc:MovieClip = new mc_class();

            And that's it, unfortunatelly not all the properties are copied so you'll have to do a copy props function

            copyProps(f, new_mc);

            private function copyProps(orig:MovieClip, dest:MovieClip):void {
            dest.transform = orig.transform;
            dest.filters = orig.filters;
            dest.cacheAsBitmap = orig.cacheAsBitmap;
            dest.opaqueBackground = orig.opaqueBackground;

            //Copiemos el 9grid si es necesario
            if (orig.scale9Grid) {
            var rect:Rectangle = orig.scale9Grid;
            // Flash 9 bug where returned scale9Grid is 20x larger than assigned
            rect.x /= 20, rect.y /= 20, rect.width /= 20, rect.height /= 20;
            dest.scale9Grid = rect;

            hope it works