A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Problem with LoadVars

  1. #1
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24

    Problem with LoadVars

    I am having a problem using LoadVars. I have the following functions in a Flash movie.


    function testForVars() {
    dataSender = new LoadVars();
    dataReceiver = new LoadVars();
    dataSender.sendAndLoad("retTest.html",dataReceiver ,"POST");

    dataReceiver.onLoad = showRetVals;
    }

    function showRetVals() {
    trace("retval1 = "+this.retval1);
    trace("retval2 = "+this.retval2);
    trace("retval3 = "+this.retval3);
    trace("retval4 = "+this.retval4);
    trace("retval5 = "+this.retval5);
    }


    and the following HTML page ( - added to tags so they show)


    <-HTML>
    <-HEAD>
    <-TITLE>Var Test<-/TITLE>
    <-/HEAD>
    <-BODY>

    retval1=50&retval2=65&retval3=dog&retval4=785&retv al5=house

    <-/BODY>
    <-/HTML>


    When I run the .swf the result is

    retval1 =
    retval2 = 65
    retval3 = dog
    retval4 = 785
    retval5 = house

    <-/BODY> (no dash in output)

    <-/HTML> (no dash in output)

    Does anybody have any idea how to get the first value to show and the <-/BODY> and <-/HTML> to not show in the output? I cannot see how the tags are getting into Flash.

  2. #2
    Senior Member
    Join Date
    Feb 2003
    Posts
    825
    why not create a separate html file that loads the flash into it?

    you can still render the text as HTML, but won't need the <-html><-/html>, etc...b/c when the page is loaded into the browser, it will be there from the external html file...

  3. #3
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Try changing:

    retval1=50&retval2=65&retval3=dog&retval4=785&retv al5=house


    to:

    &retval1=50&retval2=65&retval3=dog&retval4=785&ret val5=house



    Hope this helps.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  4. #4
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    I added the &. This gives me the value for retval1. I still see the tags pulled into Flash though.

  5. #5
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Try putting a ; at the end of the line


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  6. #6
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    Originally posted by iguanagirl32
    why not create a separate html file that loads the flash into it?

    you can still render the text as HTML, but won't need the <-html><-/html>, etc...b/c when the page is loaded into the browser, it will be there from the external html file...
    I am using a Stand alone projector to run diagnostics on a database. I have no problem with pages that just verify the database is saving by returning a single error code. If I try and return multiple values I am running into this problem. The existing pages are .asp and work correctly. I am using HTML as a test page and that is how I came across this problem. The HTML is not actually a part of the Flash output, it is just being loaded by LoadVars.

  7. #7
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    Originally posted by Lightwave Network
    Try putting a ; at the end of the line
    I tried this and it just adds ; to the last value :-( It sounded promising.

  8. #8
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    It looks like LoadVars doesn't like working in this way with a .html page. If I save the page as an .asp page it works with no problem. Go figure.

  9. #9
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    It looks like LoadVars doesn't like working in this way with a .html page. If I save the page as an .asp page it works with no problem. Go figure.

  10. #10
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    I'm just as confused as you are....



    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  11. #11
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    I wonder if this is a known bug in Flash

  12. #12
    Junior Member
    Join Date
    Jul 2000
    Posts
    5

    Well, it's a fix...

    I've never used sendAndLoad like you are here, so I dl'ed your code, and ran it, and I got the same problem. I spent about 5 minutes trying to pull something like this:
    PHP Code:
    retval5 retVal.substr(0retval5.indexOf("\r")); 
    but I got nothing. I finally just cut it off the same way you made your first variable appear... I appended a "&" after the last variable in the html code, which tells flash that thats the end of retval5. the tag garbage still gets loaded I think, it just doesn't get assigned to anything valuable... hope this helps...

    grins,
    -J

  13. #13
    StudyDog System Designer
    Join Date
    Jun 2003
    Location
    Portland, OR
    Posts
    24
    Luckily I am going to be using .asp anyway, so it is not a big deal. I would have thought that it would have worked the same in .html.
    OH WELL!!!

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