A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [F8] local connection over multiple SWF's

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    682

    [F8] local connection over multiple SWF's

    I want to embed multiple copies of the same SWF in a page, and use local connection to pass a variable to all of those SWF's. I can get my local connection to work, but it only affects the first encountered SWF on the page, and the others seem to ignore the local connection.

    Here's a link to an example:

    http://www.cowfly.com/misc/sharedObjectTest.html

    Here's a link to the FLA I'm using:

    http://www.cowfly.com/misc/testLocalConnection.zip

    In the movie, I have a button and a dynamic text field. If my test worked as I wanted, I would be able to push the button and the text field in all of the SWF's on the page would read "It worked". However, only one of them works.

    How can I get all of the SWF's to recognize the localConnection?

    What I eventually want to do is to have multiple audio players embedded in a page and tell them all to stop if any one starts, but first I have to figure this out. I've previously used the ExternalInterface API for this, but in this case I need localConnection.

    Also, here's the code from frame one for anyone who doesn't want to download the FLA:

    //------------------------------------------------------------------------------
    listeningLC = new LocalConnection();

    listeningLC.toPlayer = function(playControl) {

    if (playControl == 1) {
    playControl = 0;
    testText = "It worked"
    }
    };
    listeningLC.connect("lc_outgoing");

    //
    testButton.onPress = function() {
    talkingLC = new LocalConnection();
    playControl = 1;

    talkingLC.send("lc_outgoing", "toPlayer", playControl);
    //
    }

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Hi Kenny.... couldn't see any fault in the code you have used.

    i have a working file with interaction between 3 swf files at -

    http://www.jackleaman.co.uk/test/loc...ion/index.html

    download the zip and pick it apart, it might help

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    That's some nice coding, but it looks like yours communicates from movie 1 to movie 2 and then from movie 2 to movie 3 - right? I really want to find a solution that lets me use only one swf. Maybe it's not possible?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    all files are interconnecting - 1 to 2, 1 to 3, 3 to 2, 3 to 1,
    1 and 3 are senders, 2 is a receiver only

    i haven't tried the approach you are using with one swf repeated
    i'll give it a go over the weekend and get back to you

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    Thanks!

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Hi .. all tests end with the same result .. only the first swf is activated

    my only thoughts are (untested) name each swf with a number -
    a0.swf, a1.swf, a2.swf..
    use _url to pull in the file path/name - str = _url
    find the dot - dot = str.lastIndexOf(".");
    find the number - num = str.charAt(dot-1);

    somehow incorporate the number into the localConnection

    as i state it's all untested, but if this helps, or you find
    some other way of getting it to work, please let me know.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    Quote Originally Posted by a_modified_dog
    Hi .. all tests end with the same result .. only the first swf is activated

    my only thoughts are (untested) name each swf with a number -
    a0.swf, a1.swf, a2.swf..
    use _url to pull in the file path/name - str = _url
    find the dot - dot = str.lastIndexOf(".");
    find the number - num = str.charAt(dot-1);

    somehow incorporate the number into the localConnection

    as i state it's all untested, but if this helps, or you find
    some other way of getting it to work, please let me know.
    Thanks for testing and verifying this. Your idea has me thinking... I bet I could use FlashVars to give each localConnection it's own unique name and then for loop through the possibilities. I'll try to test this soon.

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