How do I create an specific name to objects in an for?

You must Login before you can answer or comment on any questions.

I'm trying to give specific names to my images view in an for loop something like that

for( var i = 0; i < 5; i++ ){
    // give specific names to each image view to be able to change something after
    var imageView[i] = Ti.UI.createImageView({
        image: "image"
    })
}
anyone know how to do that?

thanks

1 Answer

Accepted Answer

var imgs = [];
for( var i = 0; i < 5; i++ ){
    // give specific names to each image view to be able to change something after
    imgs[i] = Ti.UI.createImageView({
        image: "image"
    });
}
 
// access via
imgs[2].image = "newimagevalue.png";

Your Answer

Think you can help? Login to answer this question!