2 Replies Latest reply on Aug 30, 2009 1:55 AM by 435.mahesh

    How to add button to applicationControlbar?

    435.mahesh Level 1

      Hi
      Here i have linkbutton(below the controlbar) and applicationcontrobar.
      My requirement is wen i clicked on linkbutton(add) then button(admin) will be added to
      Controlbar dynamically.How to achieve this?

       

      --
      Regards
      D.Mahesh Babu

        • 1. Re: How to add button to applicationControlbar?
          Andrew Rosewarn Level 3

          Hi

           

          You could go about this in two ways.  One would be to actually create the button dynamically and add it like this;

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

          <mx:Script>

          <![CDATA[

          private function addBar():void {

          var linkButton:LinkButton = new LinkButton();

          linkButton.label = 'Admin';

          cBar.addChild(linkButton);

          }

          ]]>

          </mx:Script>

           

          <mx:Panel x="173" y="90" width="250" height="200" layout="absolute">

          <mx:ControlBar id="cBar">

          </mx:ControlBar>

          </mx:Panel>

          <mx:LinkButton label="LinkButton" x="184" y="319" click="addBar()"/>

           

          </mx:Application>

           

          You'd then have to add listeners to the new button for click events etc through code.  Or you could create the button in mxml with listeners etc in place and use the visible and includeInLayout properties to initially hide, and then show the button.

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

          <mx:Script>

          <![CDATA[

          private function showMe():void {

          adminBtn.includeInLayout = true;

          adminBtn.visible = true;

          }

          ]]>

          </mx:Script>

           

          <mx:Panel x="173" y="90" width="250" height="200" layout="absolute">

          <mx:ControlBar id="cBar" >

          <mx:LinkButton id="adminBtn" label="Admin" visible="false" includeInLayout="false"/>

          </mx:ControlBar>

          </mx:Panel>

          <mx:LinkButton label="LinkButton" x="184" y="319" click="showMe()" />

           

          </mx:Application>

           

          I hope this is of help.

           

          Andrew

          • 2. Re: How to add button to applicationControlbar?
            435.mahesh Level 1

            thaq my problem solved