dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: help with using simple variable

  1. #1
    Member
    Join Date
    Feb 2001
    Posts
    60

    Dynamic variables different than manual var?

    I have no idea why this simple variable isn't working.

    I'm familiar with variables, and using them fine. However, when I call variables from a text field, they seem to act differently when I use them as expressions.

    My situation:

    Frame 1 of root
    I load the variables.txt file. One of the variables is &totalStaff with a value of 1

    Frame 2
    My dynamic text box verifies the variable (totalStaff) has loaded and says 1

    I also have a button which says

    on (release) {
    gotoAndStop ("staff" + totalStaff);
    }

    It doesn't go to frame label "staff1". If I try setting the variable manually in the timeline on frame 1 everything works fine. But when I load it from the text file it doesn't. I have even tried referencing _root.totalStaff ==1 but the same occurs. I have also tried:

    on (release) {
    if (_root.totalStaff == 1) {
    gotoAndStop("staff1");
    }
    }

    No luck. Help?

  2. #2
    Senior Member
    Join Date
    May 2002
    Posts
    248
    The only thing I can think is that _root.totalStaff really doesn't equal 1. Maybe it's 1 plus a carriage return, or some other weird thing. So I would try tracing _root.totalStaff with some delimiter on either side of it, just to see exactly what it's set to. Like<pre>trace("*" + _root.totalStaff + "*");</pre> That way you know that it's set to exactly what you see between the asterisks. Also, you could try using parseInt, which would simply extract the integer 1, leaving any other garbage off. Like<pre>on (release) {
    gotoAndStop ("staff" + parseInt(totalStaff));
    } </pre>
    -Dan

  3. #3
    Member
    Join Date
    Feb 2001
    Posts
    60
    Thanks so much, Dan.

    I had never heard of parseInt, but it worked perfectly!

    -paul

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    248
    Cool man, glad to help!
    -Dan

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