A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: loadVariables vs. getURL?

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    7

    loadVariables vs. getURL?

    I have gotten my form in Koolmoves to interact with a php program, yet I am not able to see in the movie or receive back into the movie the variables I sent via the below statement, executed in the movie, when a button is clicked on:

    on (release) {
    loadVariables("bfcpassword.php","POST")
    }

    When I change the above loadVariables statement to
    on (release) {
    getURL(“bfcpassword.php”,”POST”)
    }

    I then am sent to the bfcpassword.php page, which displays the Koolmoves variable names & their modified values, via several php ‘print’ statements. I am using, in bfcpassword.php,

    print “&txt1var=”.$txt1var;
    print “&txt2var=”.$txt2var;
    etc…

    The variable names are the same as the variable name(s) for several dynamic text boxes within the movie, i.e. dynamic text box ‘txt1’ has its variable name set to ‘txt1var’.

    The bfcpassword.php program is correctly operating on the variables sent from the movie – it is changing their values based on computations within the bfcpassword.php program.

    Yet, I can not seem to get the values for the variables to ‘refresh themselves’ within the dynamic text boxes in the movie.

    Am I doing something wrong in the bfcpassword.php program, by using print statements?
    Or is my loadVariables statement incorrectly formatted so as to receive back to the movie the results of the computations within the bfcpassword.php program? Both the movie and the php program reside within the same directory on the server.

    Thanks for any assistance.

    Tom

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    LoadVariables dosen't wait for data to return so you have to do the waiting. This is were LoadVars is a better choice as it has events like onData.

    Look up the syntax and usage here. Note you must convert the examples to AS1.0 from 2.0 but that's not very hard.
    http://livedocs.macromedia.com/flash...rt4_ASLR2.html

  3. #3
    Senior Member indogo's Avatar
    Join Date
    Dec 2005
    Posts
    282
    Try _root.loadVariables or this.loadVariables had a similar problem and this cured it.

    Your code otherwise is ok and should update the varables/textfield in a static movie.
    The only other drawback with this method is that all variables in the same movieclip are sent which loadVars solves.

    have fun

    mike

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    If your movie is stopped I don't think the a textbox will get updated. Before LoadVars I used script timers to look for the data. That's where loadVars is great you don't have to wait for the data.

    Events rock man....

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    code:

    //Create LoadVars object
    my_lv= new LoadVars();
    //set the data to send

    my_lv.txt1var=_root.txt1var
    my_lv.txt1var=_root.txt1var

    my_lv.onData = function(src) {
    txt1.text = src;
    };
    my_lv.sendAndLoad("bfcpassword.php", my_lv, "POST");


  6. #6
    Junior Member
    Join Date
    Mar 2006
    Posts
    7
    Thanks to everyone for their help. I am new to actionscript as well as PHP. Both share similarities to a language I used eons ago - IBM PL/1.

    tom

  7. #7
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Events rock man....
    No doubt. The loadVars class is worlds away from the old method. If it's a standard GET or POST it's not such a big deal (ok...it is )but almost all forms expect a response from the backend and that is where that class rocks.

  8. #8
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I remember my first email form I did with 3dfa and loadvariables. I spent a fair amount of time figuring out how to "wait" for a response before allowing the user to continue. First time I discovered I could use LoadVars in KoolMoves I was excited as it was SOoooo simple to get when the server responded.

  9. #9
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Yeah...I chuckle everytime I see one of my old source codes with loop code and watcher clips and such. That class made it all outdated in an instant. Gotta be one of the top five classes to learn huh?

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