dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: LoadVars & Conditional Statement , help needed...

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Posts
    113

    LoadVars & Conditional Statement , help needed...

    I am having trouble running a contitional statement againsed data that I have received through LoadVars.

    Pretty simple really, will it should be... although id does have me stumped.


    "recieved" is my loadvars object, Status is the variable that will = 0 on a correct login... a trace or dyanamic text box shows it as a 0 however the if statement doesn't recognize it as one. Anyone know what the problem is or a way arround?

    I imagine this is something to do with the loadvars variable, but I have tried setting the condition to itself, it works, the loadvars to another variable, it doesn't...

    if(recieved.Status==0){
    // the screen it should go to when logged in
    gotoAndPlay("main");
    }
    else{
    // the loop
    gotoAndPlay("logincheck");

    }

  2. #2
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    I believe the problem is the way flash sees the "0" if I use Math.floor() on it it returns NAN, yet if I test againsed it as a string it still doesn't yeild me the desired result. It shows up as "0" in a text field, neither statement below would see the if fullfilled.

    if(passedVariable == "0")
    if(passedVariable == 0)

    Is there a way to change the way flash sees a variable, force it to be a number ? Could flash be seeing it as binary or something? Perhaps the full &myLoadVar.Varable=0 ? (although that doesn't show up like that on traces nor did it seem to work when I tried)

    Any help would be greatly appreciated...

    Thankyou =)

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    Wok

    Try using it in this form:

    Number(recieved.Status)

    Though it sounds like you are having a similar problem to me, see "Perl and Flash Variables" below.

    Let me know if you get the Flash to "see" the conditional state.

    swills

  4. #4
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    I will check out your thread.

    That just gave me NaN also =(

    Thanks for trying =)

  5. #5
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    TTT

  6. #6
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    Anyone got any ideas? I still havn't been able to work this out =(

    I am getting the varialbe from a CGI script...

    Incase you were wondering this is all done only after the variable is loaded though a handler, so it isn't the common mistake of no loop...

  7. #7
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    Wok

    read the post I started with Flash and Perl variables - Musicman came up with the solution....just send back the data from your cgi without the _root. bit , but still normal headers.

    Worked for me

    swills

  8. #8
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    This is all happening in the main movie, for me... could it be that the "status" as a variable name is messing it up?

  9. #9
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    things that mess up...
    - a variable name matching that of a function - you dont have function status() somewhere in your movie
    - pathed variables sent back from the cgi - use
    print "status=xxx";
    rather than
    print "_root.status=xxx"
    - whitespace and line breaks
    print "&status=xxx";
    will work, but
    print "status = XXX";
    will not work.

    Musicman

  10. #10
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    Nope not the same name as a function.

    Status is a reserved word though (it shows up blue) in flash... does this make any difference?

    Second one, it is part of a loadvars object called recieved (called in when it is loaded) I had recieved.status I believe that is correct? Shows up fine in traces... so does _root.recieved.status

    Pehaps the white space in the cgi scipt is an issue I will double check, it shows up in the trace though...


    Thanks for you help =)

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