2 Replies Latest reply on Mar 12, 2016 4:42 PM by johnl34897798

    setChildIndex is being overridden by embedded SWF

    johnl34897798 Level 1

      Hello all I am trying to embed a SWF file into my project and place some navigation buttons over top of the SWF. The SWF is a 360 panoramic photo and in the past this has worked just fine, but now it seems the SWF is overriding my action script and pushing itself to the top layer over my navigation buttons. Below is my action script. Any help would be appreciated.



      //Sets the layer of display for the items below

      setChildIndex(cockpitInstructions_mc,numChildren -1);

      setChildIndex(cockpitVideo_mc,numChildren -2);

      setChildIndex(cockpitVideo2_mc,numChildren -3);

      setChildIndex(CockpitHeader_mc,numChildren -4);

      setChildIndex(homeButton1_mc,numChildren -5);

      setChildIndex(infoButton1_mc,numChildren -6);

       

       

      //Sets the movie clips below invisible

      cockpitVideo_mc.visible = false;

      cockpitVideo_mc.stop();

      cockpitVideo2_mc.visible = false;

      cockpitVideo2_mc.stop();

       

       

      //Embeds the pano .swf file

      import flash.net.FileReference;

      var requestVariable = new URLRequest("test-01.swf");

      var loaderVariable:Loader = new Loader();

      var booleanVariable:Boolean = false;

      loaderVariable.load(requestVariable);

      addChild(loaderVariable);

      setChildIndex(loaderVariable,numChildren -7);

       

       

      //Button to navigate back to the home movie

      homeButton1_mc.addEventListener(MouseEvent.CLICK, onhomeButton1Click);

       

      function onhomeButton1Click(e:MouseEvent):void

       

      {

      removeChild(homeButton1_mc);

      removeChild(CockpitHeader_mc);

      loaderVariable.unloadAndStop();

      gotoAndPlay(1);

       

      }

       

      //Button to play the info movie clip

      infoButton1_mc.addEventListener(MouseEvent.CLICK, oninfoButton1Click);

       

      function oninfoButton1Click(e:MouseEvent):void

       

      {

      cockpitVideo_mc.visible = true;

      cockpitVideo_mc.play();

       

      }

       

      //Button to play second half of the info movie clip

      cockpitVideo_mc.addEventListener(MouseEvent.CLICK, oncockpitVideoClick);

       

      function oncockpitVideoClick(e:MouseEvent):void

       

      {

      cockpitVideo_mc.visible = false;

      cockpitVideo_mc.stop();

      cockpitVideo2_mc.visible = true;

      cockpitVideo2_mc.play();

      }

       

      //Removes movie clip from stage when clicked

      cockpitVideo2_mc.addEventListener(MouseEvent.CLICK, oncockpitVideo2Click);

       

      function oncockpitVideo2Click(e:MouseEvent):void

       

      {

      cockpitVideo2_mc.visible = false;

      cockpitVideo2_mc.stop();

      }

       

      // Timer to remove instruction movie clip

      var minuteTimer:Timer = new Timer(6500, 1); 

      minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

      minuteTimer.start();

       

      function onTimerComplete(event:TimerEvent):void

      {

      removeChild(cockpitInstructions_mc);

      }

        • 1. Re: setChildIndex is being overridden by embedded SWF
          Colin Holgate MVP & Adobe Community Professional

          You have so many setchildindex lines going on that it could be confusing. If you want to set the layering of some items, so that the top seven items are on top of everything else, and in a particular order, you could use addChild(). That puts the object to the front, if you did that for the top seven items they would be on top, and in the right order.

           

          For these lines:

           

          addChild(loaderVariable);

          setChildIndex(loaderVariable,numChildren -7);


          you could use addChildAt() instead, and have the loaderVariable at the correct level right away. 

          • 2. Re: setChildIndex is being overridden by embedded SWF
            johnl34897798 Level 1

            It turns out that there was something within the external SWFs that were overriding the layer numbering. Experimented with different 360 pano software and found that Garden Gnome Pano is the only one that worked. Didn't have to change the setChildIndex lines.