1 Reply Latest reply on Feb 26, 2007 6:03 PM by Newsgroup_User

    Local Connection REWIND gone awry...

    kevin_stagg Level 1
      I uploaded a sample of a local connection onto a blank white page:

      http://www.staggclan.com/test/localconnection/index.html

      It has a "stop", "play" and "rewind" button at the top in the buttons.swf and initially, as Mozart loop plays - if you press "play" or "stop" or "rewind", then they behave as expected.

      *The problem lies when you press rewind and THEN hit "stop" - the button is not functional.

      The code I have set up for STOP button on first frame is:

      on (release) {
      outgoing_lc = new LocalConnection();
      outgoing_lc.send("hello", "test", "stop");
      delete outgoing_lc; // drop the connection
      }

      The code I have set up for PLAY is:

      on (release) {
      outgoing_lc = new LocalConnection();
      outgoing_lc.send("hello", "test", "play");
      delete outgoing_lc; // drop the
      connection
      }

      The code I have set up for REWIND is:

      on (release) {
      outgoing_lc = new LocalConnection();
      outgoing_lc.send("hello", "test", "rewind");
      delete outgoing_lc; // drop the connection
      }


      NOW - for the actual audio.swf, I have the following actionscript set up on first frame:

      incoming_lc = new LocalConnection();
      incoming_lc.connect("hello");

      incoming_lc.test = function
      (whatToDo)
      {
      if(whatToDo == "play")
      play();
      else if(whatToDo == "stop")
      stop();
      else if(whatToDo == "rewind")
      gotoAndPlay(1);
      }

      ....for the life of me I can't figure out why neither the "stop" buttons wouldn't work after hitting rewind?

      Your help on this matter is GREATLY, GREATLY appreciated.


        • 1. Re: Local Connection REWIND gone awry...
          Level 7

          > ....for the life of me I can't figure out why neither the "stop" buttons
          > wouldn't work after hitting rewind?

          You must not re-run this code when you do the rewind :

          incoming_lc = new LocalConnection();
          incoming_lc.connect("hello");
          incoming_lc.test = function (whatToDo)
          {
          var _loc1 = whatToDo;
          if (_loc1 == "play")
          {

          etc..

          When you hit rewind and gotoAndPlay(1) it runs that code again, messing up the connection.
          You need to put that code inside a one-time only code or gotoAndPlay(2) to avoid hitting that code at frame 1 again.
          If you want a one-time only code, just wrap that code section inside a flag variable like this..

          if(!initialized)
          {
          initialized = true; // flag prevent this code from running again after a rewind

          incoming_lc = new LocalConnection();
          incoming_lc.connect("hello");
          incoming_lc.test = function (whatToDo)
          {
          var _loc1 = whatToDo;
          if (_loc1 == "play")
          {
          etc...
          }
          }


          tralfaz