11 Replies Latest reply on Jun 22, 2006 7:45 PM by kglad

    Sending MultiplePrameters with Localconnection

    erye
      Hi. I am inexperienced coder. I am extracting data from an XML file and sending it to another file using Local Connection. To Display the text I extraxt in dynamic text fields in the reciver movie. The problem is I need to send multiple parameters to the reciever movie.
      When I look for examples all i can find are one showing only one parameter being sent.
      Like this:
      new LocalConnection();
      outgoing_lc.send("myDomain:_lc_name", "aMethod", "This is a string parameter");
      delete outgoing_lc;

      What I want to do is more like this:
      new LocalConnection();
      outgoing_lc.send("myDomain:_lc_name", "aMethod", "title_txt.text, name_txt.text, description_ txt.text, sizes_text.txt"); when i try thsionly thefirst parameter show up. I amnot sure what i'm doing wrong.
      does ayone have any advice or examples?

      Is LocalConnection the best way to do this?
      Is there a way to send an image paths as paramaters instead of text?

      Thank you for your help,
      Lisa
        • 1. Re: Sending MultiplePrameters with Localconnection
          kglad Adobe Community Professional & MVP
          you're sending one comma delimited string. if you want to send more than one string, do so.

          the localconnection class has no trouble handling more than one parameter, string or otherwise. however, you can't send objects or object references if those objects don't exist in the receiving swf.
          • 2. Re: Sending MultiplePrameters with Localconnection
            erye Level 1
            Thank you for replying. I think the problem is i don't know how to get the receiver move to display the parameters I want to send to it. For instance in the receiver movie i am suing
            this code to display the prameter
            myLocalConnection = new LocalConnection();
            myLocalConnection.onReceive = function(param) {
            sentMessage_txt.text = param;
            STYLPW_txt.text = param;
            };

            I have two dynamic fields on the stage one named sentMessage_txt and one named STYLPW_txt but when I run the file only sentMessage_txt appears.
            How can I split the parameters up so the reciver movie understands it needs it its receiving and needs to display mutlple messages?

            As you cacn see i'm barely past writing function and learnins (slowly) as i go. That's why I asked for examples in my first post. any help you can give is really appreciated.
            • 3. Sending MultiplePrameters with Localconnection
              erye Level 1
              woops. Looks like the message got posted twice for some reason.
              • 4. Re: Sending MultiplePrameters with Localconnection
                Level 7
                "erye" <webforumsuser@macromedia.com> wrote in message news:e773ep$ec$1@forums.macromedia.com...
                > Thank you for replying. I think the problem is i don't know how to get the
                > receiver move to display the parameters I want to send to it. For instance in
                > the receiver movie i am suing
                > this code to display the prameter
                > myLocalConnection = new LocalConnection();
                > myLocalConnection.onReceive = function(param) {
                > sentMessage_txt.text = param;
                > STYLPW_txt.text = param;
                > };
                >
                > I have two dynamic fields on the stage one named sentMessage_txt and one named
                > STYLPW_txt but when I run the file only sentMessage_txt appears.
                > How can I split the parameters up so the reciver movie understands it needs it
                > its receiving and needs to display mutlple messages?
                >
                > As you cacn see i'm barely past writing function and learnins (slowly) as i
                > go. That's why I asked for examples in my first post. any help you can give is
                > really appreciated.

                It's not complete, but maybe the parts that you're not showing have the problem.
                tralfaz


                • 5. Re: Sending MultiplePrameters with Localconnection
                  kglad Adobe Community Professional & MVP
                  there is no onReceive method for the localconnection class. the correct way for the receiving swf to respond to the sending swf is to define the function (in the receiving swf) that's called by the send method in the sending swf.

                  so, for example:

                  • 6. Re: Sending MultiplePrameters with Localconnection
                    erye Level 1
                    Thanks for these answers kglad and tralfaz. i've got it working now. I 've got a few more
                    questions. Mostly about how to send image path from the reciver movie. I'll think about a sensible question and post it tomorrow.
                    • 7. Re: Sending MultiplePrameters with Localconnection
                      kglad Adobe Community Professional & MVP
                      you won't be sending anything from the receiver swf unless you create another localconnection object and make the receiver swf also a sender swf.

                      or maybe you could use the same localconnection object. i've never tried that.
                      • 8. Re: Sending MultiplePrameters with Localconnection
                        erye Level 1
                        Hello again. Next thing I need to do is send an image path from the sender movie(not the recivever movie as I said before) as a parameter.

                        The image path i need is generated by the XML file I load in the sender movie Like this:

                        function processXML(success:Boolean):Void{
                        if(success) {
                        var filename:XMLNode = rootNode.childNodes[13].childNodes[0].nodeValue;
                        loader_mc.loadMovie("images/" + filename);

                        I am not sure how to code the sender movie to change the resulting path into a parameter so the recieving movie can display the path. I thought ._url might be the right way to do this but i am stil pretty lost.

                        SENDER MOVIE
                        this.sender_btn.onPress= function(){
                        myLocalConnection = new LocalConnection();
                        myLocalConnection.send("incomingMessage", "textDisplay", title_txt.text, STYLPW_txt.text,STYLPW3_txt.text,sentImage._url);
                        myLocalConnection.close();
                        };
                        RECEIVER MOVIE
                        where i create an empry movie clip toload the photo

                        this.createEmptyMovieClip (mcInstance="detailPhoto_mc",this.getNextHighestDepth());

                        myLocalConnection = new LocalConnection();
                        myLocalConnection.connect("incomingMessage");
                        myLocalConnection.textDisplay = function(p1,p2,p3,p4)
                        {
                        sentMessage_txt.text = p1;
                        STYLPW_txt.text = p2;
                        STYLPW2_txt.text = p3;
                        /*the code below is incorrect*/
                        detailPhoto_mc.loadMovie(p4);
                        };

                        • 9. Re: Sending MultiplePrameters with Localconnection
                          kglad Adobe Community Professional & MVP
                          if you remove the var that prefixes filename in processXML() (and eliminate the data typing), you can use:

                          myLocalConnection.send("incomingMessage", "textDisplay", title_txt.text, STYLPW_txt.text,STYLPW3_txt.text,"images/"+filename);

                          or use another variable to store your path if you don't want to fiddle with filename.
                          • 10. Re: Sending MultiplePrameters with Localconnection
                            erye Level 1
                            Hi. I am still having trouble. I think I want to keep to the data typing. It is good coding practice, no? So instead I tried to create another variable to store the image path. No luck.

                            I tried this :
                            loader_mc.loadMovie("images/" + filename);
                            var imgFile = filename.toString();
                            trace(imgFile);

                            which gives me the path I want in the output window.

                            But when I get to the receiver movie it shows up as undefined in the output window. What Do I need to change? I've posted the code at http://209.89.142.173/section/sectionbrand06/dev/xml3.html to save some space here.
                            Maybe you can have a look at the code and see if i need to change something there?

                            What I probably need is a tutorial on creating and passing dynamic image paths and perhaps a blazing hot cup of tea. yes. I could really use that. Im not in a beer mood. But I'll take some tutorial links if you have them. i read the ones at kirupa.com and I am for a few others.

                            Thanks for all your help,

                            • 11. Re: Sending MultiplePrameters with Localconnection
                              kglad Adobe Community Professional & MVP
                              you misunderstand something that's fundamental and is going to continue to cause you problems when you use flash until you learn how to handle the concept of when to use and not use the flash keyword var.

                              var is not a throw-away word that you use to prefix the initial declaration of all your variables. var specifically makes the variable that follows it "a local variable". there are some times when it's ok to use it. some times when you really need to or should use it. and there are many more times when you should not use it.

                              specifically, you should not use the var keyword unless you intend to make the variable that follows this keyword, local to the function or for-loop in which the variable is defined. now, re-read that sentence and check the flash help documents until you understand what that means. it will save you many hours of debugging time if and when you understand its use.

                              your link shows you are committing the same error with imgFile that you were with filename. fix that. eliminate the var prefix.