A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: increment value in textbox

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Posts
    540
    how would I increment a value (1, 2, 3, 4, etc.) in a textbox. The value is to be incremented by one each time object1 hits object2. I have this...but it stays at 1.

    var cal = i;
    i = 1;
    if (this.hitTest(_root.box1)){
    _root.score = i++;
    }
    }

  2. #2

    var cal = i;
    i = 1;
    if (this.hitTest(_root.box1)){
    _root.score = i++;
    }
    } [/B][/QUOTE]

    Don't use the variable method. Use the object method:

    Assuming yoor score field is given an instance name of score_txt (always use _txt as a prefix, so that the code editor gives you code clues)

    var cal = i;
    i = 1;
    if (this.hitTest(_root.box1)){
    _root.score_txt.text = i++;
    }
    }

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Posts
    540
    can you explain a little more why I need to use the .text and give the textbox an instance name? I thought that by giving it a var name was enough. Is this new to flash mx?



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