Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
Posts: 42
Registered: ‎03-01-2011
My Device: Not Specified

Continuous\ Panning scroll gallery

Hi all,

 

Not really a problem, more of a request for feedback.

 

I have currently built a grid based image gallery which uses next/back buttons to take you through the pages of images. Ideally I would like to achieve a gallery which had continuous scrolling functionality, just like the native pictures application that comes with the device, so that the users can 'drag' the gallery of images across the screen, loading the new images as the gallery is moved.

 

I don't want to load all of the images at once as each gallery will have hundreds of images, I would rather only load the images which are within the viewing area of the screen. Does anyone know of a way to deal with this? I didn't know if I could write a custom cell rendererfor each 'grid page' in the gallery and then use the imageCache Class like below:

 

http://renaun.com/blog/2011/01/using-qnx-image-and-imagecache-in-list-custom-cellrenderer/

 

Any ideas or suggestions would be appreciated.

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: Continuous\ Panning scroll gallery

I've done something similar in my app (http://appworld.blackberry.com/webstore/content/49236) but it is fairly complicated due to asynchronous loading from the virtualized file system.

 

Take a look at Lee Brimelow's excellent tutorial:

 

http://www.leebrimelow.com/?p=2839

 

He uses static images embedded into the .swf for simplicity, but it could easily be modified to use an ImageCache or other technique. The only difficuly is that you'll have ensure that the image - or a correctly sized placeholder - is available when it is needed. If your images are of mixed size & aspect ratio that may be difficult.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Contributor
Posts: 44
Registered: ‎02-21-2011
My Device: Playbook

Re: Continuous\ Panning scroll gallery

I wrote my own photo scroller for my app and was trying to approach it in the same way as you. Have you checked out the scrollRect class?

 

scrollRect

 

it defines a scrollrectangle where your graphics are only rendered when they enter the bounds of the rectangle. I found that it is less CPU intensive but it isn't quite as smooth as if you load all the images simultaneously. For the best results you need to set the cachasBitmap value to true for your display objects that you are scrolling.

-------------------------------------------------------------------------------------------

Check out MyBestShot for the playbook in Blackberry Appworld.
Contributor
Posts: 42
Registered: ‎03-01-2011
My Device: Not Specified

Re: Continuous\ Panning scroll gallery

Thanks for your suggestions, least I have a starting point and some things to try.

 

I'll try to put together a simple example and I'll try post the source back for some feedback if that's ok.

 

Cheers again.

Contributor
Posts: 42
Registered: ‎03-01-2011
My Device: Not Specified

Re: Continuous\ Panning scroll gallery

UPDATE:

 

I managed to get a simple example working by using a TileList with a custom cell renderer and ImageCache for the images inside of the renderer. It seems to work well, now I just need to figure out a way to detect when the end of the TileList is reached so I can load anothet set of images (I'm loading in batches of 30).

 

I'll try post the source up later today.