3 Replies Latest reply on Oct 28, 2006 1:32 PM by kglad

    local connection objects

    >Vee< Level 1
      I am communicating between two swfs.
      I have done so by using the local connection object. The problem Im having is that I cannot send two methods at one time to the receive.swf. Each sending of lc_name and lc_jump works if I send them at different times (or rather one at a time). What I was really looking to do is send/receive two each at one time. Heres what doesnt work:

      this.createTextField("result_txt", 1, 10, 10, 100, 22);
      result_txt.border = true;
      var receiving_lc:LocalConnection = new LocalConnection();
      receiving_lc.methodToExecute = function(param1:Number, param2:Number) {
      result_txt.text = param1+param2;
      receiving_lc.switchFrame = function(param3:Number) {
      receiving_lc.connect("lc_name", "lc_jump");

      code in send.swf:
      btn_0.onRelease = function() {
      // Code in the sending SWF file
      var sending_lc:LocalConnection = new LocalConnection();
      //sending_lc.send("lc_name", "methodToExecute", 10, 10);
      // second code to receiving SWF
      sending_lc.send("lc_name", "methodToExecute", 10, 10+"lc_jump", "switchFrame", 2);

      As you can see this line:
      //sending_lc.send("lc_name", "methodToExecute", 10, 10);
      without comments works fine on its own and togther with the other method "lc_jump". "lc_jump" and its parameter doesn't work together with the lc_name but does work if you segragate it.
        • 1. Re: local connection objects
          kglad Adobe Community Professional & MVP

          • 2. Re: local connection objects
            >Vee< Level 1
            It works. Honestly I can't understand why. Only once does it receive and twice it sends. I take it everytime you want to send more function calls with parms you keep building to the send and not the receive, is that right?
            • 3. Re: local connection objects
              kglad Adobe Community Professional & MVP
              the receiving lc needs multiple functions defined if you want to cause the execution of multiple functions from the sending lc.

              each send method can cause one function in the receiving lc to execute. so, if you want multiple functions to execute you need to use a different send() method for each one.

              the connect method of the receiving lc only needs to execute once to open the connection. it will then continually listen to see if any of the lc functions are called.

              the connect method can cause the same function to execute repeatedly (if repeated send() methods are executed) or different functions to execute (if different send methods naming those functions are executed).