tags:

views:

106

answers:

2

I want to change the image at click event.I change the source of the image on click but its not reflecting immediately it comes when any other event is fired.Why is it so and anyone have the solution??

A: 

Call image.validateNow() after setting the source to force the change immediately.

Amarghosh
A: 

If you are setting the source to a url (such as image.source = "/assets/myimage.jpg"), then it could take 1+ frames to load the image since it is making an asynchronous URLRequest, so the change wouldn't be registered immediately. Calling validateNow() wouldn't help in that case.

If you need it to load immediately, either embed the images (if they're small enough) or load a few of them at a time and store them somewhere, and set the image source to the bitmap (something like image.source = myImageCache.getBitmap(0);).

Hope that helps, Lance

viatropos