A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: URLLoader data in conditional statement not recognized? AS3

  1. #1
    Junior Member
    Join Date
    Apr 2009

    Cow Icon URLLoader data in conditional statement not recognized? AS3


    I am loading data from php using the echo method into flash via the URL loader:URLLoader method. The data then gets assigned to an object.

    My problem is that the loaded data is being imported in fine and I can trace it and even display it in a text box, but if I try and use this data in a conditional statement - the statement just won't recognize its value?

    Below is a sample of my code..
    I'm pulling my hair out atm..

    My PHP---v
    $row = mysql_fetch_array($query);
    echo "result=success";
    echo "&unit=$row[unit]";

    My AS3---v
    var loader:URLLoader = URLLoader(e.target);
    var result = loader.data.result;

    if (result == "success")
    var n = loader.data;

    if (n.unit == "inchs") {

    else {

    My problem is in green above. The variable/data being imported in is indicating which measuring unit the user preferred - "inchs" for inch's or "cms" for centimeter's.

    The statement never seems to recognize this data and always proves false and 'else' is executed.

    However if I instruct the data to be displayed in a text box eg.
    "display.text = n.unit;" The text box displays the correct result as if the data has came across fine?

    Any help would be greatly appreciated. Cheers

  2. #2
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    What does it say if you trace the following:

    trace("_" + n.unit + "_");

    My guess you have a white space being printed in the php script.

  3. #3
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    you echo statment should look like this

    [ php]
    echo "result=success&unit=$row[unit]";


  4. #4
    Junior Member
    Join Date
    Apr 2009

    Thumbs up


    SPOT ON! yeah there is a whitespace to the left??? echo's (_inch _)???

    Im making adjustments now... any ideas why this happens?

    Much appreciated.. Thanks for your help!

Tags for this Thread

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