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
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)

Loading Images from Array

Ok, here goes:

 

I have the following set up

                //container to display images
                album = new Container();
		album.margins = Vector.<Number>([15,15,15,15]);
		album.setPosition(15,15);
		album.setSize(994,285);
		album.graphics.beginFill(0x333333, 1);
		album.graphics.drawRect(0,0,994,285);
		album.flow = ContainerFlow.HORIZONTAL;
		album.align = ContainerAlign.MID;
		pictures.addChild(album);
			
		//images placeholder
		image000 = new Image();
		image000.setImage("assets/pics/pic1.png");
		image000.width = (512);
		image000.height = (260);
		image000.containment = Containment.CONTAINED;
		image000.x = ( album.width - image000.width )/2;
		image000.y = ( album.height - image000.height )/2;
		album.addChild(image000);
			
                //array with image and item info
array7 = new Array(); array7.push({label: "item 1", Image:"assets/pics/pic1.png"}) array7.push({label: "item 2", Image:"assets/pics/pic2.png"}) myData7 = new DataProvider(array7);

 Now, I also have to lists. The first list pulls its data from a dataProvider, and when a list item is clicked if find what the selectedIndex is and loads the corresponding array into a second list. As you can see above I obviouslydon't want the images to go into that second list, I want them to go in the top half of my page.

 

 

My question concerns setImage. How do I get setImage to show the image that corresponds with the selected index of 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 -
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Loading Images from Array

If you are setting the image from the attribute "Image" (BTW, to avoid bugs, best to keep object attributes lower case, IMHO), but it is not loading, try prefixing the URL with "file://".  Also be certain that those files exist on the simulator.  If you are dynamically scanning a directory for a a list of images, you may still need to prefix the URL to get the image to load the path correctly.

Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)

Re: Loading Images from Array

Thanks, but I'm able to get my images to load.

 

I think you actually answered my question in a separate thread though lol, so I'm going to give that a try!

- 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 -
Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)

Re: Loading Images from Array

I set it up like this and everything works great:

 

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")

I don't need to have the images in an array because they're specified in the function.

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 -
Please use plain text.