title: Create elements and addEventListener with Loop in Titanium Appcelerator
body: <p>Using Titanium Appcelerator I am trying to dynamically create elements and add event listeners to them using a loop. Here is my current code:</p>
  
  <pre><code>for(i=0;i&lt;7;i++){
  
  testLabels[i] = Titanium.UI.createLabel({
      borderRadius: 35,
      text:'hello',
      textAlign:'center',
      width:70,
      height: 70,
      top: '13%',
      left:140,
      touchEnabled: true
  });
  
      testLabels[i].addEventListener('click',function(e){
          //do something
      }
  }
  </code></pre>
  
  <p>When I run this I get the following error: </p>
  
  <pre><code>Can't find variable: testLabels. 
  </code></pre>
  
  <p>Its interesting to me that the variable it can't find isn't "testLabels1", which to me means the loop isn't firing... any ideas?</p>
  
  <p>Thanks!</p>
  
  <p>Titanium doesn't like it when I place "var" in front of the label declaration.</p>