dcsimg
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
    Posts
    4

    Cow Icon URLLoader data in conditional statement not recognized? AS3

    Hi,

    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 {
    }

    END CODE
    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
    Location
    Sweden
    Posts
    1,626
    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
    Location
    Earth
    Posts
    2,588
    you echo statment should look like this

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

    [/php]
    ~calmchess~

  4. #4
    Junior Member
    Join Date
    Apr 2009
    Posts
    4

    Thumbs up

    @strille

    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