You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by chris_d_k <ck...@christiankiefer.de> on 2014/10/31 19:34:16 UTC

Multiline Label in Spark Mobile Button

Is there any example for a multiline button in flex mobile skin written in
ActionScript? 



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Multiline-Label-in-Spark-Mobile-Button-tp8562.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Multiline Label in Spark Mobile Button

Posted by chris_d_k <ck...@christiankiefer.de>.
This is displaying the button in a correct way but inside a list the gaps are
broken... seems the time measure was called there were calculated some wrong
values...

public class QuadMultilineButtonSkin extends ButtonSkinBase
	{

	
		public function QuadMultilineButtonSkin()
		{
			super();
			layoutBorderSize = 0;
		}

		override protected function createChildren():void
		{
			super.createChildren();
			labelDisplay.multiline = true;
			labelDisplay.wordWrap= true;
			labelDisplay.setStyle("fontWeight", "normal");
			labelDisplay.setStyle("fontSize", 20);
			labelDisplay.setStyle("textAlign", "left");
		}

		override protected function commitCurrentState():void
		{
			super.commitCurrentState();
			// update borderClass and background
			invalidateDisplayList();
		}

		override protected function measure():void
		{
		    super.measure();
			labelDisplay.commitStyles();
			measuredHeight = labelDisplay.getPreferredBoundsHeight() + 20;
		}

		override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
		{
		    super.updateDisplayList(unscaledWidth, unscaledHeight);
			setElementSize(labelDisplay, labelDisplay.getPreferredBoundsWidth(),
labelDisplay.getPreferredBoundsHeight());
			setActualSize(unscaledWidth, labelDisplay.getPreferredBoundsHeight());
			setElementPosition(labelDisplay, 10, 10);
		}

		override protected function drawBackground(unscaledWidth:Number,
unscaledHeight:Number):void
		{
			graphics.clear();
			if(currentState == "down")
			{
				graphics.beginFill(QuadButton(hostComponent).downColor, 1);
			}
			else
			{
				graphics.beginFill(QuadButton(hostComponent).upColor, 1);
			}
			graphics.drawRect(0,0,unscaledWidth,
labelDisplay.getPreferredBoundsHeight() + 20);
			graphics.endFill();
		}

	}



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Multiline-Label-in-Spark-Mobile-Button-tp8562p8563.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.