A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Really simple script doesnt work :S

  1. #1

    Really simple script doesnt work :S

    Im trying to + a number into a dyn. textbox....

    like:

    myVar += 1;

    But that or non of the other methods i have tried works :S

    Anyone got an idea?

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298
    Assuming you mean that you have a text box on the stage set to dynamic and you gave it an instance of myVar...
    A dynamic text box is an object with text as an attribute. That attribute is a string. So you may have the number in the box but it is actually a string.

    So you change the value of the text with
    Code:
    myVar.text = "whatever";
    therefore if you are using the box to show a number, you need to convert the string value of the number to a number before you can increment it.
    Code:
    // they are shorter ways to write this but for simplicity sake...
    currentNum = Number(myVar.text);
    nextNum = currentNum + 1;
    myVar.text = nextNum;
    Hooe that helps
    ---
    Thinking outside of the box will get you fired if the "box" is strict budget.

  3. #3
    Member
    Join Date
    Feb 2003
    Location
    local habitation
    Posts
    73
    code:

    myVar = 0;
    onEnterFrame = function(){
    myVar += 1;
    dynTextBox_txt.text = myVar;
    }



    Don't forget to give the text box the instance name: dynTextBox_txt
    Zaffer

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