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
New Contributor
rohildev
Posts: 4
Registered: ‎02-05-2013
My Device: BlackBerry Dev Alpha

Change background color of LabelButton

Hi, How can i change background color of LabelButton in Flex?

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series

Re: Change background color of LabelButton

To change Label background you need to setskin of  labelButton 

 

package 
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import qnx.fuse.ui.skins.SkinAssets;
	import qnx.fuse.ui.skins.SkinStates;
	import qnx.fuse.ui.skins.UISkin;
	import qnx.fuse.ui.skins.text.TextInputSkin;
	
	
	public class CustomTextSkin extends TextInputSkin
	{
		/**@private**/
		protected var upSkin:Sprite;
		/**@private**/
		protected var disabledSkin:Sprite;
		/**@private**/
		protected var downSkin:Sprite;
		
		/**
		 *Create a custom button skin
		 */
		public function CustomTextSkin()
		{
			super( );
		}
		override protected function getSkinForState(state : String) : DisplayObject
		{
			var asset : DisplayObject;
			
			switch (state)
			{
				case SkinStates.UP:
					if( upSkin == null )
					{
						upSkin = new Sprite() ;
						upSkin.graphics.beginFill(0xFFFFFF , 0.0 ) ; 
						upSkin.graphics.drawRect(0 , 0 , 600 , 86 ) ; 
					}
					asset = upSkin;
					break;
				case SkinStates.DOWN:
					if( downSkin == null )
					{
						downSkin = new Sprite() ;
						downSkin.graphics.beginFill(0xFFFFFF , 0.0 ) ; 
						downSkin.graphics.drawRect(0 , 0 , 600 , 86 ) ;
					}
					asset = downSkin ;
				case SkinStates.DOWN_SELECTED:
				case SkinStates.SELECTED:
					if( downSkin == null )
					{
						downSkin = new Sprite() ;
						downSkin.graphics.beginFill(0xFFFFFF , 0.0 ) ; 
						downSkin.graphics.drawRect(0 , 0 , 600 , 86 ) ;
					}
					asset = downSkin;
					break;
				case SkinStates.DISABLED:
				case SkinStates.DISABLED_SELECTED:
					if( disabledSkin == null )
					{
						disabledSkin = new Sprite();
						disabledSkin.graphics.beginFill(0xCC0000);
						disabledSkin.graphics.drawRect(0,0,200,200);
						disabledSkin.graphics.endFill();
					}
					asset = disabledSkin;
					break;
			}
			return asset;
		}
	}
}

Save above code as CustomTextSkin.as in your Project by creating ActionScript class.

 

 to set it as Your Labelbutton.. Use.. 

<LabelButton Object>.setSkin(CustomTextSkin) ;

 

 

Please use plain text.
Developer
Deepu_George_Jacob
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380

Re: Change background color of LabelButton

Use opaqueBackground mentioned below

opaqueBackground="0xff000"
Please use plain text.
New Contributor
rohildev
Posts: 4
Registered: ‎02-05-2013
My Device: BlackBerry Dev Alpha

Re: Change background color of LabelButton

I need to change the background color of LabelButton. opequeBackground not changing the full background.. it still showing the default back color around the Label inside the Button. How to change that color. 

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series

Re: Change background color of LabelButton

Have you tried the workdone to do as i have provided you ?
Please use plain text.
Developer
Deepu_George_Jacob
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380

Re: Change background color of LabelButton

I am not using label buttons. I place image as button and add four events (mouse over, mouse up, mouse down, mouse out)
Please use plain text.
New Contributor
rohildev
Posts: 4
Registered: ‎02-05-2013
My Device: BlackBerry Dev Alpha

Re: Change background color of LabelButton

i need to add this button inside the Grid to list some values. So i need to change the back color. 

Is there any way to change background color of items in the List or Grid

Please use plain text.