A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Local Connection Multiple Functions

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    6

    Local Connection Multiple Functions

    Hello,


    I have two exe files and I am trying to control one with the other in two different windows (Sender / Reciever Windows)

    I am doing this in AS2 simply because the original set-up (single screen set-up now they want a second screen) was done awhile back in AS2 and I didn't want to recreate it...this is old and its not important to do it the best, cleanest way but just to get it done.

    I got the first function to work but can't get the second function to work and I don't know why...new to local connection function so obviously I am missing something.

    I have tried doing the Code for each button individually trying to create a new connection each time one appears and in one frame on its own layer to control all buttons on one LocalConnection as well but no luck:

    Sender Code:


    sending_lc = new LocalConnection();

    mybtn1.onRelease = function() {
    sending_lc.send("my_lc_as2", "execute_this", gotoAndPlay(2));
    }

    mybtn2.onRelease = function() {
    sending_lc.send("my_lc_as2", "execute_this", gotoAndPlay(4));
    }

    Reciever Code:

    receiving_lc = new LocalConnection();

    receiving_lc.execute_this = function(){
    gotoAndPlay(2);

    }

    receiving_lc.connect("my_lc_as2");


    receiving_lc.execute_this = function(){
    gotoAndPlay(4);

    }

    receiving_lc.connect("my_lc_as2");


    In essence I am trying to get buttons (6 in total) on Sender to forward the receiver exe to a new frame on release. The button "mybtn1" is working and sending the reciever movie to frame 2. The button "mybtn2" however does nothing and I am obviously not putting this together correctly.

    This is a mock-up. There are six buttons of which only one of the six are on the stage at anytime. Every time the Receiver advances to a new frame then the sender advances to a new frame as well until they finish...for the sender file the advance is a simple gotoAndPlay on the button itself.

    In all cases I get the first button to work to advance both the receiver and sender to a new frame, but not the second

    Any ideas how I can get all six of my buttons advancing both the sender to a new frame as well as the receiver? very frustrated...If you would like to see the originals let me know and I can send them. Or if you are able to mock something up in a file that has the first two buttons working and send it, then I can complete.

    Thanks

    chris

  2. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    PHP Code:
    //Sender//
    sending_lc = new LocalConnection();
    mybtn1.onRelease = function() {
        var 
    command="F_2";
        
    sending_lc.send("Sender","execute_received",command);//gotoAndPlay(2));
    }; 
    PHP Code:
    //Receiver//
    receiving_lc = new LocalConnection();
    receiving_lc.execute_received = function(str:String) {
        if(
    str=="F_2"){
            
    mc.gotoAndStop(2);
        }
    };
    receiving_lc.connect("Sender"); 

    You can make in 2 way communication.

    Read for more about this:

    http://help.adobe.com/en_US/FlashPla...onnection.html



    arkitx
    Last edited by arkitx; 07-23-2013 at 07:15 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center