tags:

views:

213

answers:

2

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?

+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
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
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
oh.. great.. thanks a lot..
Angeline Aarthi
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