Several images in a ImageView
Hi I'd like to load several images in a ImageView, I tried :
var mobilier = ['images/2/meuble_01.jpg',
'images/2/salle-de-bain_01.jpg'];
var mobilier = [{url:'images/2/meuble_01.jpg'},
{url:'images/2/salle-de-bain_01.jpg'}];
But both don't work. How should I declare my images array ?
Thanks
11 Answers
-
try putting
image.start();
after adding it to the window
-
var mobilier = []; mobilier[0] = 'images/2/meuble_01.jpg'; mobilier[1] = 'images/2/salle-de-bain_01.jpg'; Ti.API.info('mobilier array '+mobilier); Ti.API.info('array '+mobilier); var image = Titanium.UI.createImageView({ url:mobilier[0], images:mobilier, //width:'150', touchEnabled: true, duration: 2000, repeatCount: 0 }); // listen for load event (when all images are loaded) image.addEventListener('click', function() { // start animation image.start(); }); image.addEventListener('dblclick', function() { // start animation image.stop(); }); // listen for start event (when animation is started) image.addEventListener('start', function() { Titanium.API.info('ImageView animation started'); }); // listen for stop event (when animation is stopped) image.addEventListener('stop', function() { Titanium.API.info('ImageView animation stopped'); }); // listen for change event (when animation is changed) image.addEventListener('change', function(e) { Titanium.API.info('ImageView animation frame has changed, index ' + e.index); }); win1.add(label1); win1.add(image);
I dont know what you're trying to do but this shows the first image of the animation, then when you click on it , the animation starts, then doubleclick it stops, I left most of your listeners and stuff there, you can tweak it from here I think
Rob
-
I tried this :
var mobilier = []; mobilier[0] = 'images/2/meuble_01.jpg'; mobilier[1] = 'images/2/salle-de-bain_01.jpg';
But same trouble, nothing is displayed.
And the rest of my code is :
var image = Titanium.UI.createImageView({ //url:restauration[0], images:mobilier, width:'700px', touchEnabled: true }); image.start(); image.show();
-
2 things,
did the array display in the main box where all the text scrolls when its building the app for the simulator?and did you add image to the current window
Titanium.UI.currentWindow.add(image);
-
Yep
[INFO] array images/2/meuble_01.jpg,images/2/salle-de-bain_01.jpg
And Yes, later in my code I do :
win1.add(image);
I tried another thing :
var image = Titanium.UI.createImageView({ //url:restauration[0], images:mobilier, width:'700px', touchEnabled: true, duration: 2000, repeatCount: 0 }); // listen for load event (when all images are loaded) image.addEventListener('load', function(e) { // start animation image.start(); }); // listen for start event (when animation is started) image.addEventListener('start', function() { Titanium.API.info('ImageView animation started'); }); // listen for stop event (when animation is stopped) image.addEventListener('stop', function() { Titanium.API.info('ImageView animation stopped'); }); // listen for change event (when animation is changed) image.addEventListener('change', function(e) { Titanium.API.info('ImageView animation frame has changed, index ' + e.index); });
And I got all the messages well displayed but still no image. :S
-
I don't understand I do have the same code, but no image is displayed. I guess it's not yet completely implemented in the iPad project and/or in the iPad simulator :/
-
Try explicitly specifying a width and height property for your imageViews
I have a feeling that width and height MUST be specified for it to work.
(Once you have the image load, you can then determine the actual widths and height and adjust accordingly.)
-
I assume the window you are adding to is called 'win1' ??
I just ran the same code in a window on an ipad project and it worked, positioning was off between initial image and animation but click to start and double click to stop worked fine.
slash star your animation code / yourcode /
and try adding a simple label to see if you can see that, if you can't then there is something up with your page creation, tab or window or something, if the label works then i'm afraid i am stumped!!
var label1 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 1', font:{fontSize:20,fontFamily:'Helvetica Neue'} }); win1.add(label1);
-
OK, now it works, I have specified a width and a height. Thank you very much.
I think before it was displayed but outside of the screen.
-
Can I just ask how you make these boxes with the background when you put in your codes? I have no idea how?
-
var myArray = [];
myArray[0] = "Football";
myArray[1] = "Baseball";
myArray[2] = "Cricket";Ti.API.info('array '+ myArray);//displays the array contents so you can see if it works
google is your friend