Dynamic EventListener
I created an array where thumbnails are loaded into a view and pushed into an array dynamically.
it all works fine etc etc the images are outputted into a scrollview and it works fine.
Now I want to change the backgroundImage for win1 to change accordingly to the thumbnail pressed.
So i need to get the correct id of the image
I click on parijs.png (1st thumbnail) it should change the background to paris
If I click on thumbnail nr 8 (thailand) it should change the background to thailand.
I add a addEventListener dynamically (open_page) to check the source from eacht thumbnail with e.source.image
it works fine BUT.
the loop for the click starts at 10 instead of 0
so when I click on the 1st thumbnail (paris) it should give me back './pages/thumbs/images/parijs.png'
but it gives me back:
'./pages/thumbs/images/antartica.png'
and the next is:
'./pages/thumbs/images/moskou.png'
and then the 3rd thumbnail also gives me:
'./pages/thumbs/images/moskou.png'
what the hell is wrong with this? this has been driving me crazy the whole weekend XD
heres the code:
http://pastie.org/1263772
3 Answers
-
Anyone? this is really starting to get annoying..
-
Seriously, Do I have to anwser most if not all my questions myself ?
This is pretty frustrating I can't seem to understand if this is a difficult problem.
-
Patrick
I have just looked at your problem, including trying to get your code running locally, but it's not altogether straightforward. We could mock up something similar, but then we would not be certain to see the same behaviour. This kind of help really does take more time and effort than it may appear from your perspective.
Please help the community to help you, by creating a simple version of your script. Strip out all superfluous properties and methods, until it is in its most basic form, but still exhibits the problem. Make the array 4 element in length, or less if possible). Please provide some assets (if you want to protect IP, just create simple blocks of colour, at the right dimensions, uploaded to imageshack or similar). Also, make sure it works (note that "pages" is undefined in your snippet). Lastly, tell us your target platform and SDK version.
Note that currently you have contentWidth:'3200', but the quotes are not required. You should remove them.
I'll check back tomorrow for updates.
Cheers