2 Replies Latest reply on Jun 25, 2008 2:10 PM by bhnh

    AS 101 question on loops

      I'm stuck on something that's really fundamental and it's driving me nuts.

      I've got five buttons labeled "btn_1", "btn_2", etc. When a button is pressed, I'd like to trace it's corresponding number. When I try this:

      for(var i:Number=1;i<6;i++){
      this["btn_"+i].onPress = function(){

      ... it traces "6" regardless of which button is pressed. I know I'm missing a variable somewhere, but my grey matter's crapped out. Help? Many thanks in advance.