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
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Sorting Lists

Ah.  Then you probably dont need the thumbnail image in the list.  So your original thought is correct.  Keep the URL to the image as an attribute to the items in the list.  Listen for a change event to the list (Event.CHANGE), and then set the main image to the URL in the list from:

 

mymainimage.setImage( mylist.selectedItem.image );

Make certain the image URL is a full url that can be loaded.  You may need to prefix the URL with "file://" depending on the images location.

Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Sorting Lists

Wow, that might be exactly what I'm looking for. I'm going to give it a shot

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Sorting Lists

Ok, so I already have this eventListener for my first list:

private function onClick(e:ListEvent):void{
			
if(list.selectedIndex==0) rlist.dataProvider = myData0 	
if(list.selectedIndex==1) rlist.dataProvider = myData1 
if(list.selectedIndex==2) rlist.dataProvider = myData2

 

 

and it works perfectly. Am I able to do the following to specify what item is clicked in the second list (as just saying index==0 or 1 won't work as the item changes)

 

 

private function onClick(e:ListEvent):void{
			
if(list.selectedIndex==0 and rlist.selectedIndex==0) image = "assets/pics/img1.png" 	
if(list.selectedIndex==0 and rlist.selectedIndex==1) image = "assets/pics/img2.png" 	
if(list.selectedIndex==0 and rlist.selectedIndex==2) image = "assets/pics/img3.png" 	

 or change the image = part to tie in directly with the corresponding line in the array?

 

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Sorting Lists

Wow, I actually figured it out....

 

 

private function rlistClick(e:ListEvent):void{
	
if(list.selectedIndex==0 && rlist.selectedIndex==0) image000.setImage("assets/pics/img1.png")		
if(list.selectedIndex==0 &&rlist.selectedIndex==1) image000.setImage("assets/pics/img2.png")		
if(list.selectedIndex==0 && rlist.selectedIndex==0) image000.setImage("assets/pics/img3.png")		
if(list.selectedIndex==0 && rlist.selectedIndex==1) image000.setImage("assets/pics/img4.png")		

 

 

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Sorting Lists

 


jtegen wrote:

Ah.  Then you probably dont need the thumbnail image in the list.  So your original thought is correct.  Keep the URL to the image as an attribute to the items in the list.  Listen for a change event to the list (Event.CHANGE), and then set the main image to the URL in the list from:

 

mymainimage.setImage( mylist.selectedItem.image );

Make certain the image URL is a full url that can be loaded.  You may need to prefix the URL with "file://" depending on the images location.


Just wanted to update that whenever i had

 

mymainimage.setImage( mylist.selectedItem.image );

the debugger would crash. Taking that line out though had no effect on my app and it still works perfectly.

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Sorting Lists

Is the item selected?  Try:

 

if( mylist.selectedItem )

  mymainimage.setImage( mylist.selectedItem.image );

else

  trace( 'item not selected' );

 

 

Highlighted
Developer
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Sorting Lists

That's a lot closer to the code I'm using. I was putting it in the image attribute and the if attribute at first, and it wasn't needed in the image attribute section.
- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -