2 Replies Latest reply on Jun 16, 2010 7:47 PM by celebritymusic

    Getting external swf to stay visible?

    celebritymusic Level 1

      Hi

       

      I have an external swf that contains a button that controls my main swf's timeline.

       

      I can get it to navigate fine, but as soon as it navigates, my external swf disappears, because my main swf is no longer on the frame my external swf was imported on.

       

      How do I get the external swf to stay visible along all the frames of my main swf's timeline?

       

      Here's the code I use to import the external swf:

       

      var external_swf:MovieClip;
      var loader:Loader = new Loader();

       

      var import_me_SWF:URLRequest = new URLRequest("external_mc.swf");

       

      loader.load(import_me_SWF);
      loader.x = 0;
      loader.y = 0;
      addChild(loader);

       

      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);

       

      function dataOnLoad(evt:Event): void {
      external_swf = MovieClip(evt.target.content);

      }

       

       

       

      Thanks guys.

       

      Shaun

        • 1. Re: Getting external swf to stay visible?
          celebritymusic Level 1

          OK - I've figured it's the index 'loader' that's the problem.

           

          I can use setChildIndex(loader, numChildren -1); 

           

          ...this sets loader to be on top of whatever is already display.

           

          BUT 'loader' ends up behind anything that gets displayed in the future

           

          Is there a way to tell Flash to ALWAYS display 'loader' on top, no matter what gets displayed in the future?

           

          Thanks

           

          Shaun

          • 2. Re: Getting external swf to stay visible?
            celebritymusic Level 1

            SOLUTION:

             

            Ok - here's a solution I experimented with for anyone that needs a similar fix:

             

            1. Create a new layer where you would like the external swf to go (in my case, the layer is on the top).

             

            2. Draw a rectangle (doesn't matter what it is really), convert it to a movieclip symbol, and give it a color effect APLHA of 0 so it's invisible.  Give it an instance name - I named mine 'external_swf_holder'

             

            3. Adapt the external loader code like this...add 'external_swf_holder' to the beginning of the external clip name, with a dot in between:

             

            var external_swf:MovieClip;
            var loader:Loader = new Loader();

             

            var  import_me_SWF:URLRequest = new URLRequest("external_mc.swf");

             

            loader.load(import_me_SWF);
            loader.x  = 0;
            loader.y = 0;
            addChild(loader);

             

            loader.contentLoaderInfo.addEventListener(Event.COMPLETE,  dataOnLoad);

             

            function  dataOnLoad(evt:Event): void {
            external_swf_holder.external_swf =  MovieClip(evt.target.content);

            }

             

            4. That's it.  Now Flash should always keep your swf on the layer that 'external_swf_holder' is on.

             

            Cheers

             

            Shaun