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: 217
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone
Accepted Solution

(bb10) TileList add row background

Hi all!

 

Is there a way to add a "per row" background image to a TileList?

I want mi TileList to have a background for each row, no matter the number of columns on it. Is it possible?

 

Something similar to this... Can I create a background image for any container repeating the same image until completing the height of the container?

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Developer
Posts: 217
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: (bb10) TileList add row background

This might help others.

I solved it this way.

Add an sprite as the first component so as it is in the background.

Then add as may images vertically as rows has the list.

Finally update the background position when the list is scrolled.

That's all.

 

package com.xplota.components
{
	import com.xplota.Events.EpubEvent;
	import com.xplota.assets.Icons;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import mx.utils.ObjectUtil;
	
	import qnx.events.ScrollerEvent;
	import qnx.fuse.ui.display.Image;
	import qnx.fuse.ui.events.ScrollEvent;
	import qnx.fuse.ui.listClasses.TileList;
	
	public class MyTileList extends TileList
	{
		private var im:Image=new Image();
		private var background:Sprite=new Sprite();

		public function MyTileList()
		{
			super();
			im.addEventListener(Event.COMPLETE, paintBackground);
			im.setImage("assets/estante2.png");
			this.addEventListener(ScrollEvent.SCROLL_MOVE, scrollMove);
		}
		override protected function init():void
		{
			this.addChild(background);
			super.init();
		}

		private function paintBackground(e:Event=null):void{
			background.removeChildren();
			var numchilds:int=Math.max(Math.ceil(this.height/this.rowHeight), this.rowCount);
			for(var i:Number=0; i<numchilds; i++){
				addImageBackground();
			}
		}
		private function addImageBackground():void{
			var im2:Image=new Image();
			im2.setImage(im.bitmapData);
			im2.setPosition(0, background.numChildren*im2.height);
			background.addChild(im2);
		}
		private function scrollMove(e:ScrollEvent):void{
			background.y += e.deltaY;
		}
		override public function addItem(arg0:Object):void{
			super.addItem(arg0);
			if(this.rowCount>background.numChildren){
				addImageBackground();
			}
		}
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			paintBackground();
		}
	}
}

 

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords