13 Replies Latest reply on Oct 28, 2006 4:40 PM by Newsgroup_User

    toString help

    thanx4allthefish
      Hi,

      If I do a sendandLoad to an asp program and I do a .toString on the returned data what should I expect to see? I seem to be getting the entire asp document displayed. I don't know whether this is correct. If it isn't correct does it mean that IIS isn't working properly or I need to set the encoding to something else? Does interaction with asp work correctly by doing TestMovie ?

      Any help appreciated.



        • 1. Re: toString help
          Level 7
          thanx4allthefish,

          > If I do a sendandLoad to an asp program and I do a .toString
          > on the returned data what should I expect to see? I seem to be
          > getting the entire asp document displayed.

          That sounds about right.

          To use the LoadVars class, you're supposed to call send(), load(), or
          sendAndLoad(), as you've done. In the case of load() and sendAndLoad() your
          specified target object becomes populated with properties based on the
          results. I don't know how you set up your ASP form, but if the returning
          data contained a name/value of food="cereal", you'd find a food property
          whose value was "cereal" in the object. Does that make sense?


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: toString help
            thanx4allthefish Level 1
            Thanks for the reply.

            I am totally confused now. I posed an original question earlier which was this about passing info back from asp -

            =======

            I trace what's passed back in Flash to see the result.

            I just need to know why the following syntax doesn't work -

            Response.Write("&r_cnt=" & rvar & "&") (rvar hardcoded as 0)

            rvar is just a variable value I want to pass back. When I run this in Flash it says the value of r_cnt is "

            If I type -

            Response.Write("&r_cnt=0&") and run it through, the value of r_cnt is traced as 0 correctly.

            I can't see why the concatenation using rvar doesn't work.

            =========

            From what I can tell Flash is receiving back the entire contents of the ASP page so the name/value pair works when hardcoded, but once a variable is used it thinks that the " character after the = is the value.

            I am trying to run this under TestMovie.

            I can only think that either the asp interaction doesn't work correctly under TestMovie, or asp is not working correctly or are there some MIME settings that need configuring??? I'm totally at a loss at the moment.
            • 3. Re: toString help
              Level 7
              thanx4allthefish,

              > From what I can tell Flash is receiving back the entire contents
              > of the ASP page so the name/value pair works when hardcoded,
              > but once a variable is used it thinks that the " character after the
              > = is the value.

              You're combining technologies here, so it's probably best to
              troubleshoot one, then the other. Since ASP is the originator of the data,
              let's start there first. What do you get when you post to this ASP page
              from an HTML form? Or, if all it does is return a result ... do you get the
              desired string in the browser when you hit that page?


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: toString help
                thanx4allthefish Level 1
                Basically all I'm trying to do right now is test that I can get sendandLoad to work. I have a Fla movie with a sendandLoad action in it,. I then do Control Test Movie which fires up the swf. On the click of a button it performs the sendandLoad which goes off into my bit of asp which doesn't do anymore than return a value back. I trace the return value back in Flash. I have a trace(recvar.toString) within the onload function in Flash and this seems to return my entire asp document in a URL encoded format. So Response.Write("&r_cnt=0&") in asp shows up as Response%2EWrite%28%22=&r%5Fcnt=0&%20%22 (snippet only) in Flash and asp Response.Write("&r_cnt=" & rvar & "&") traces back as Response%2EWrite%28%22=&%20%22=&%20rvar%20=&r%5Fcnt=%22%20&%20%22. In the 1st one if I trace recvar.r_cnt it shows 0, and in the 2nd one it traces a " . I read somwhere on the Flash site about having the MIME type set, could it be something to do with that?
                • 5. Re: toString help
                  Level 7
                  thanx4allthefish,

                  > Basically all I'm trying to do right now is test that I can get
                  > sendandLoad to work.

                  I'm with ya.

                  > I have a Fla movie with a sendandLoad action in it,. I then
                  > do Control Test Movie which fires up the swf. On the click
                  > of a button it performs the sendandLoad which goes off into
                  > my bit of asp which doesn't do anymore than return a value
                  > back.

                  Right. That's what value?

                  > I trace the return value back in Flash.

                  Before you trace it in Flash, I'm suggesting you hit the ASP page on
                  your own, in a browser, to test what string the page returns.

                  > I have a trace(recvar.toString) within the onload function in
                  > Flash

                  The "onload function"? Is this the LoadVars.onLoad event?

                  > and this seems to return my entire asp document in a URL
                  > encoded format.

                  That probably makes sense, given then you're using the
                  LoadVars.toString() method.

                  > So Response.Write("&r_cnt=0&") in asp shows up as
                  > Response%2EWrite%28%22=&r%5Fcnt=0&%20%22 (snippet
                  > only) in Flash

                  The unescape() function converts urlencoded text into text that's easier
                  to read. :) But again, what you probably *want* to do is is trace the
                  recvar.r_cnt property. I'm guessing, though.

                  > I read somwhere on the Flash site about having the MIME type
                  > set, could it be something to do with that?

                  I think you're jumping the gun. Let's make sure the string you get back
                  from ASP -- that is, the string that Response.Write() actually creates -- is
                  the string you want. When *that's* solid, then we'll step into Flash. :)


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: toString help
                    thanx4allthefish Level 1
                    Hi David,

                    Thanks for sticking with me.

                    If I display the asp in a browser it returns &r_cnt=0 on the page.

                    If I run it through Flah and trace the output (I've used unescape as you suggested), this returns the contents of my asp page with the following as the start of the output -

                    =&r_cnt=" & "', so when I trace r_cnt it returns the "

                    This is the simple bit of asp that I use as my test -

                    rvar = "0"
                    Response.Write("&r_cnt=" & rvar)

                    So it seems from this that it performs the Response.Write first without evaluating rvar at the same time, whereas browsing to the asp seems to return r_var correctly.

                    Thanks,

                    Andy
                    • 7. Re: toString help
                      Level 7
                      thanx4allthefish,

                      > Thanks for sticking with me.

                      Sure. :)

                      > If I display the asp in a browser it returns &r_cnt=0
                      > on the page.

                      Should that ampersand (&) be in there? Ultimately, you're trying to
                      return a series of name/value pairs. Sure, your series in this case is
                      comprised of one alone, but the ampersand is only needed to separate
                      name/value pairs.

                      > If I run it through Flah and trace the output (I've used
                      > unescape as you suggested), this returns the contents
                      > of my asp page with the following as the start of the
                      > output -
                      >
                      > =&r_cnt=" & "', so when I trace r_cnt it returns the "

                      Again, why use toString()? I'm not criticizing you, I'm just not sure
                      why you're going this route. If you're using the LoadVars.sendAndLoad()
                      method, one of the parameters you supply is a target object. It is into
                      this target object that the incoming properties (in this case, one) are
                      stored. Then you could traced, for example ...

                      targetObject.r_cnt

                      ... and see the value 0 (if all goes well). It's possible -- I'm not
                      sure -- that Flash thinks you're naming your variable &r_cnt instead of
                      r_cnt. But maybe that's an ASP thing that I just don't know about -- it's
                      been ages since I've used ASP.


                      David Stiller
                      Adobe Community Expert
                      Dev blog, http://www.quip.net/blog/
                      "Luck is the residue of good design."


                      • 8. Re: toString help
                        thanx4allthefish Level 1
                        Hi,

                        >Should that ampersand (&) be in there? Ultimately, you're trying to
                        >return a series of name/value pairs. Sure, your series in this case is
                        >comprised of one alone, but the ampersand is only needed to separate
                        >name/value pairs.

                        If I take the ampersand off I get undefined when I trace r_cnt


                        >Again, why use toString()? I'm not criticizing you, I'm just not sure
                        >why you're going this route. If you're using the LoadVars.sendAndLoad()
                        >method, one of the parameters you supply is a target object. It is into
                        >this target object that the incoming properties (in this case, one) are
                        >stored. Then you could traced, for example ...

                        >targetObject.r_cnt

                        I have used tostring in an effort to see what is coming back into Flash, I do trace(this.r_cnt) under an onload event which currently returns a " rather than the 0 I'm expecting.

                        I don't know what to expect when it pulls the result from asp back into Flash. Any examples of sendandLoad I've found assume it all all works perfectly, which currently for me isn't.



                        • 9. Re: toString help
                          Level 7
                          thanx4allthefish,

                          > I have used tostring in an effort to see what is coming
                          > back into Flash,

                          I hear ya. I certainly don't mean to criticize your use of it. It's a
                          great troubleshooting technique. You can also view objects in the Debugger
                          panel.

                          > I do trace(this.r_cnt) under an onload event which currently
                          > returns a " rather than the 0 I'm expecting.

                          Yeah, that kinda baffles me, too.

                          > I don't know what to expect when it pulls the result from
                          > asp back into Flash.

                          Well, that target object you pass into the sendAndLoad() method receives
                          the name/values that come back in.

                          var send_lv:LoadVars = new LoadVars();

                          At this point, you have a LoadVars() instance. You may add properties
                          to it, if you like.

                          send_lv.cereal = "Corn Pops";
                          send_lv.milk = "skim";

                          And then you can send those variables to a location, either with send()
                          or sendAndLoad().

                          sendAndLoad(" http://www.domain.com/something.php", result_lv, "POST");

                          In this case, Flash expects a separte object, result_lv, which is also a
                          LoadVars instance, to receive the results. After the data have returned,
                          result_lv will have properties that correspond to the incoming data. In
                          your case, you could then check ...

                          result_lv.r_cnt

                          If you're checking this.r_cnt, that will only work if the object in
                          question -- referenced by "this" -- was the recepient target object as
                          specified in the sendAndLoad() method.


                          David Stiller
                          Adobe Community Expert
                          Dev blog, http://www.quip.net/blog/
                          "Luck is the residue of good design."


                          • 10. Re: toString help
                            thanx4allthefish Level 1
                            Hi,

                            I tried something else last night which was to try and send the asp page to a blank page to see if it would show correctly that way. So the actionscript I used was -

                            load_grp.send("getGroup.asp", "_blank", "POST");

                            I was assuming from what I'd read that this should fire up a browser window with the executed asp in it. What it does on my machine is tries to open the file, so I get a message saying "what do you want to do with this file? open, save etc." This in a way ties in with the sendandLoad result in that it seems to open the asp file rather than run it.

                            My previous sendandLoad code was -

                            load_grp.sendandLoad("getGroup.asp", rec_grp, "POST");

                            rec_grp.onLoad = function() {
                            trace(unescape(this.toString()));
                            trace(this.r_cnt);
                            }

                            which I should have put in my post earlier.

                            There's probably some simple explanation round this, though I'm running out of ideas what to try next !

                            Perhaps the luddites are onto something :-)

                            • 11. Re: toString help
                              Level 7
                              thanx4allthefish,

                              > My previous sendandLoad code was -
                              >
                              > load_grp.sendandLoad("getGroup.asp", rec_grp, "POST");

                              Okay, so I'm seeing two LoadVars instances: load_grp and rec_grp.
                              Since load_grp is making the request to the server, it's load_grp whose
                              LoadVars.onLoad event is going to fire. Therefore ...

                              > rec_grp.onLoad = function() {

                              ... here, you should be listening to the load_grp object.

                              > trace(unescape(this.toString()));
                              > trace(this.r_cnt);
                              > }

                              load_grp.onLoad = function() {
                              trace(rec_grp.r_cnt);
                              }


                              David Stiller
                              Adobe Community Expert
                              Dev blog, http://www.quip.net/blog/
                              "Luck is the residue of good design."


                              • 12. Re: toString help
                                thanx4allthefish Level 1
                                Hi,

                                It's finally solved!

                                I don't know why, but on the send and load the asp file had to have an absolute reference to it i.e http://localhost/...getGroup.asp, and then it works !!

                                Thanks for your help and sticking with the post.
                                • 13. Re: toString help
                                  Level 7
                                  thanx4allthefish,

                                  > It's finally solved!

                                  Yessss!

                                  > I don't know why, but on the send and load the asp file had
                                  > to have an absolute reference to it i.e http://localhost/...
                                  > getGroup.asp, and then it works !!

                                  That strikes me as odd, but I won't argue with success. :)

                                  > Thanks for your help and sticking with the post.

                                  Sure thing. Glad you nailed it.


                                  David Stiller
                                  Adobe Community Expert
                                  Dev blog, http://www.quip.net/blog/
                                  "Luck is the residue of good design."