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: 63
Registered: ‎12-10-2012
My Device: Blackberry 9900

not able to set alpha value

Hai I have list where I set a background image for each row. On clicking each row i need to change the alpha value of the background image. I tried by updating the list but it doesn't work.

 

The image "images/play.png" is an icon for each element on row and the image 'image/black.png' is one I use a background of each row in list

 

for (var i:int = 0; i < array.length; i++) 
			{
				var obj:Object							= new Object();
				obj.text								= array[i];				
				obj.img									= "images/play.png";
				obj.alpha								= 1;
				//trace("Array"+array[i]);
				datapro.addItem({data&colon;obj});
			}
			mainList.dataProvider						= 	datapro;			
			mainList.addEventListener(ListEvent.ITEM_CLICKED, onLlistClick);
stage.addChild(mainList);


private function onLlistClick(event:ListEvent):void
		{
			//trace('Item is ' + event.index); 
			
			
			try{
				var obj:Object							= mainList.getItemAt(event.index);
				
				//obj										= 
				obj.alpha								= 0.5;
				obj.text								= "DSDSD";
				obj.img									= "images/play.png";				
				datapro.updateItemAt(obj,event.index);			
				mainList.dataProvider = datapro;
				//mainList.dataProvider = d
				
			}
			catch(e:Error)
			{
				trace('Exception ' + e);
			}
		}

 cellrendering 

 

package com.cellapp.list.skin
{
	import flash.display.Graphics;
	
	import qnx.fuse.ui.display.Image;
	import qnx.fuse.ui.listClasses.CellRenderer;
	import qnx.fuse.ui.text.Label;
	import qnx.fuse.ui.text.TextAlign;
	import qnx.fuse.ui.text.TextFormat;

	public class WalletSkin extends CellRenderer
	{
		public function WalletSkin()
		{
			super();
			//initBackground();
		}
		
		override public function set data(value:Object):void
		{
			// TODO Auto Generated method stub
			super.data = value.data;
			
			updateUI();
			
		}
		
		
		private function updateUI():void
		{
					
			var img1:Image 			=		new Image();
			img1.setImage("images/black.png");
			img1.alpha 				= data.alpha;
			addChild(img1);
			
			trace("alpha value is " + data.text);
			var textFormat:TextFormat = new TextFormat();
			textFormat.color		=	0xffffff;
			textFormat.align		=	TextAlign.LEFT;
			
						
			
			//trace("Name : "+data.img);
			var img:Image = new Image();
			img.setImage(data.img);
			img.x = 768 - (img.width + 100);
			img.y = 18;
			
			var oneLable:Label			=	new Label();
			oneLable.text				=	data.text;
			oneLable.format				=	textFormat;
			oneLable.width				=	768;
			oneLable.setPosition(10,5);
			
			addChild(oneLable);
			addChild(img);
			
		}
		
		
		
		
		private function initBackground():void
		{
			trace("background");
			
		}
	}
}

 please help

 

Thanks in advance

_______________________________________________________
Help is available everywhere but you have to look at the correct place.
By Me :-)
BlackBerry Development Advisor
Posts: 140
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: not able to set alpha value

This appears to be AIR?  This should be moved to the AIR forum :smileyhappy:

Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380

Re: not able to set alpha value

var obj:smileysurprised:bject = mainList.getItemAt(event.index).data;

Please use this line of code instead of var obj:smileysurprised:bject = mainList.getItemAt(event.index);