1 Reply Latest reply on Jul 24, 2010 2:19 AM by aditi_bk

    connect dispatchevent between two swf's??

    aditi_bk

      One single swf, imgdesc.swf is being loaded into the emptymcholder, by the moviecliploader instance.

       

      My order is

       

      folioholdermc ---holds--> emptymcholder --holds--> imgdesc.swf

       

      Within folioholdermc, I disabled buttons and lowered opacity, once imgdesc.swf was loaded, using onloadInit()

       

      Now  in the button inside imgdesc.swf. I called, this.unloadMovie(), which  successfully unloads the file, but I am still inside emptymcholder,  though I actually want to go back into folioholdermc.

       

      I  am trying out the use of Eventlistener to check for unloadMovie. But my  problem is can I place this within folioholdermc, within the  onloadInit() or maybe within the on(press) function which actually calls  the loader in the first place?? I need to enable the buttons within  folioholdermc, and increase opacity, once the imgdesc.swf is unloaded.

       

      Within the onLoadInit() in folioholdermc I added

       

      _mc.addEventListener("end",endClip);

       

               function endClip() {
                  trace("end");    //plan to insert code to enable buttons and increase opacity here
              };

       

      and in the imgdesc.swf within the back button

       

      on(press){
          this.dispatchEvent({target:this, type:"end"});
          trace("event dispatched");
          this.unloadMovie();
      }

       

      how do I connect the two?? This is not working, as the endClip function is not being called. What am I doing wrong???

        • 1. Re: connect dispatchevent between two swf's??
          aditi_bk Level 1

          Ok I figured it out. First mistake was that the code for dispatchevent was incomplete and placed in the wrong place, the first frame of the imgdesc.swf. The first frame of imgdesc.swf is apparently loaded before the onloadInit(), sending out an event which no one is listening to.

           

          So this is what I did within imgdesc.swf

           

          First Frame:

           

          import mx.events.EventDispatcher;

          EventDispatcher.initialize( this
          );
          stop();


          Then within the on(press) of the back button I inserted a gotoAndStop(2);

          Second Frame:

          this.unloadMovie();
          this.dispatchEvent({type:"end", target: this});

          trace("Child dispatching: end");

           

          Now in the onloadInit within the parent swf I wrote


          _mc.addEventListener("end", endClip);
                  function endClip() {
                      trace("end");
                      i = 1;

                      while (i<=30) {
                      _root.folioholdermc["img"+i]._alpha = 100;
                      _root.folioholdermc["img"+i].enabled = true;
                      i++;
                      }
                  };

           

          Worked perfectly!! Hope this helps someone else who is stuck.