I have a panel in my application. My requirement is, I also require a link, that is "Help options" to appear in the panel's header. In the left, we will have the Panel's title and in the right corner, I need this link. Is that possible?
views:
213answers:
2
Q:
Is there a way to add a link text or button to the panel header along with the panel title in Flex?
+1
A:
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="400" height="300" label="Panel's Label">
<mx:Script>
<![CDATA[
private var linkTextField:TextField;
private var _linkHtmlText:String = "";
public function set linkHtmlText(value:String):void
{
_linkHtmlText = value;
if(linkTextField)
linkTextField.htmlText = value;
}
override protected function createChildren():void
{
super.createChildren();
linkTextField = new TextField();
linkTextField.autoSize = TextFieldAutoSize.LEFT;
linkTextField.text = _linkHtmlText;
linkTextField.y = 5;
this.titleBar.addChild(linkTextField);
}
override protected function layoutChrome(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.layoutChrome(unscaledWidth, unscaledHeight);
linkTextField.x = unscaledWidth - linkTextField.width - 10;
}
]]>
</mx:Script>
</mx:Panel>
Amarghosh
2009-10-07 08:24:33
It throws an error with the line :this.titleBar.addChild(linkTextField); Severity and Description Path Resource Location Creation Time Id1119: Access of possibly undefined property titleBar through a reference with static type sample. sample/src sample.mxml line 67 1254904700318 160
Angeline Aarthi
2009-10-07 08:39:39
The code I posted is that of a whole mxml component that extends Panel. Paste it onto a new PanelWithLink.mxml and use it in your sample.mxml
Amarghosh
2009-10-07 09:03:56
oh.. great.. thanks a lot..
Angeline Aarthi
2009-10-07 09:18:12
A:
import mx.core.IUITextField;
function init():void{
var rightpanel_ui:IUITextField = rightpanel.mx_internal::getStatusTextField();
rightpanel_ui.selectable = true;
rightpanel_ui.htmlText = "<a href='/mylink.php/' target='_new'><u><font color='white'>Help</font></u></a>";
}
<mx:Panel id="rightpanel" width="100%" height="100%" status="Help">
jason
2010-06-18 20:33:37