A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: LocalConnection Help please.

  1. #1
    Member
    Join Date
    Dec 2008
    Posts
    37

    Angry LocalConnection Help please.

    Hello all, I use these forums quite often but usually do not have to post since the answers are everywhere, but I cannot seem to get this to work. I am using a webservice to populate my movie with data but I need to be able to pass 2 arrays from that first movie to my second, which will be on the webpage. The first array is a list of video sources, the second is the number of video sources available (changes daily). When I test both .swf's locally and i only send 1 array i can populate my dynamic text boxes but the movie crashes, when I send both arrays I get nothing, and it also crashes. I am using as2 in flash cs3. this is the code that i have been working with.

    Sending:

    var outgoing_lc:LocalConnection = new LocalConnection();
    sport.onRelease = function(Void):Void { outgoing_lc.send("videolist", "methodToExecute", vt, nvid);};

    Receiving:

    var incoming_lc:LocalConnection = new LocalConnection();
    incoming_lc.connect("videolist");
    incoming_lc.methodToExecute =
    function(param1:Array, param2:Array):Void { vt = param; };

    Any help at all would be greatly appreciated. ~Sean P.

  2. #2
    Member
    Join Date
    Dec 2008
    Posts
    37
    bump

  3. #3
    Banned
    Join Date
    Mar 2009
    Posts
    153
    Just try this....

    Create a dynamic textbox with instance name "checking"(don't forget to make it multiline) inside your 'receiving' swf and write this code under that frame:
    PHP Code:
    var incoming_lc = new LocalConnection();
    incoming_lc.connect("videolist");
    incoming_lc.thefunction = function(param1param2) {
        
    checking.text param1+"\n********"+param2;

    }; 
    And write this code in your 'sending' swf:

    PHP Code:
    var outgoing_lc = new LocalConnection();
    sport.onRelease = function() {
        
    outgoing_lc.send("videolist","thefunction",vt,nvid);
    }; 

    What do you get in the textbox(checking.text) ??
    Last edited by e_tit; 04-29-2009 at 02:48 PM.

  4. #4
    Member
    Join Date
    Dec 2008
    Posts
    37
    i get the data without crashing ... So now my second swf has both arrays (the names of the streams and the amount number of streams available)... How would I go about populating dynamic text boxes with this info? i have an array of text boxes called "vx", the individual text boxes are "vd1" - "vd20"... vt is the array of names (vt1 - vt?) and nvid is the amount... this seems to crash when i fire the display function though... ?


    //-----------------------------------------Receiving SWF
    var incoming_lc = new LocalConnection();
    incoming_lc.connect("videolist");
    incoming_lc.thefunction = function(param1, param2) {
    //vd1.text = param2 + "\n********"+param2;

    };

    var vx:Array = new Array(vd1,vd1,vd2,vd3, etc. etc.)

    function DisplayVideoList(){
    var i = 0;
    for (i=1;i<=nvid;i++){
    vx[i].text = vt[i];}
    }

  5. #5
    Banned
    Join Date
    Mar 2009
    Posts
    153
    Hmm... Are you actually trying to populate textboxes 'vd1 to vd20' with array values from param1. And similarly textboxes 'vt1 to vt20' with array values from param2?

    If thats the case then this should be fine:

    PHP Code:
    var incoming_lc = new LocalConnection();
    incoming_lc.connect("videolist");
    incoming_lc.thefunction = function(param1param2) {
        for (
    i=1i<=param1.lengthi++) {
            eval(
    "vd"+i).text param1[i-1]; 
            eval(
    "vt"+i).text param2[i-1];
        }
    }; 

  6. #6
    Banned
    Join Date
    Mar 2009
    Posts
    153
    Hey, i just read your first post once again. I guess you are passing the second parameter only as an identifier 'number' which contains the 'total number' of elements in array 'vt'. If thats the case you really don't need to pass this 'second' parameter, because this second parameter is anyhow going to be a number which will be the total number of array elements in the first array

    So you can simply do this:

    PHP Code:
    //receiver
    var incoming_lc = new LocalConnection();
    incoming_lc.connect("videolist");
    incoming_lc.thefunction = function(param1) {
        for (
    i=1i<=param1.lengthi++) {
            eval(
    "vd"+i).text param1[i-1];        
        }
    }; 
    //sender
    var outgoing_lc = new LocalConnection();
    sport.onRelease = function() {
        
    outgoing_lc.send("videolist","thefunction",vt); //vt is the array
    }; 
    Last edited by e_tit; 04-29-2009 at 03:52 PM.

  7. #7
    Member
    Join Date
    Dec 2008
    Posts
    37
    That worked other then that I am getting "undefined" for "vd1"? the other boxes are correct though, thank you so much for the time and help.

  8. #8
    Banned
    Join Date
    Mar 2009
    Posts
    153
    Did you miss my post#6

  9. #9
    Member
    Join Date
    Dec 2008
    Posts
    37
    bingo.

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