Adding Button(‘s) to Panel Control Bar.

This is a requirement were you wanted to add a Button or Button’s to Panel‘s Control Bar and you are wondering how to achieve this, iam telling you this is simple and the code example is given below.

Here we have to use a subtag in Panel tag control and the tag is <mx:ControlBar />

Example:

<mx:ControlBar horizontalAlign=”center” width=”385″>
<mx:Button  label=”Clear” click=”output.text =”” />
<mx:Button  label=”Clear” click=”output.text =”” />
<mx:Button  label=”Clear” click=”output.text =”” />
</mx:ControlBar>

This within the Panel mx:Tag.As below,

<mx:Panel title=”Kumar Gandhi’s Panel” x=”438″ y=”59″>
<mx:TextArea id=”output” width=”385″ height=”220″ />
<mx:TextInput id=”input” width=”385″ />
<mx:ControlBar horizontalAlign=”center” width=”385″>
<mx:Button  label=”Clear” click=”output.text =”” />
<mx:Button  label=”Clear” click=”output.text =”” />
<mx:Button  label=”Clear” click=”output.text =”” />
</mx:ControlBar>
</mx:Panel>

This gives the panel Control bar with buttons..

Panel with Buttons on ControlBar

This snap Shot shows the buttons on Panel Control Bar..

Advertisements

6 Responses to Adding Button(‘s) to Panel Control Bar.

  1. Sameer says:

    Hi,

    I want to create a link through a button. How do i go about it?
    (A link to another to another html page)

    Thanks
    Sameer

  2. kumargandhi says:

    Hi ,

    U got to use navigateToUrl () methos of the urlRequest method.

    var u:URLRequest=new URLRequest(“https://flexonblog.wordpress.com/”);
    navigateToUrl (u,”_blank”)

    u got to explore the method navigateToUrl () it has three different combinations.

    regards,
    kumar.

  3. abhishek says:

    hey,
    could we add btns to header of panel?

    • kumargandhi says:

      yes we can do this, here the header is called titleBar of the Panel.
      Code::
      var btn:Button;
      btn.width=90;
      btn.height=50;
      var hbox:HBox;
      hbox.width=300;
      hbox.addChild(btn);
      this.titleBar.addChild(hbox);
      here this is the Panel , assuming that you use this code inside a Panel., On CreationComplete.

      regards,
      kumar.

      • Nirmal Kumar says:

        Hi Kumar,

        I have tried the code you gave for putting the button on the titlebar of the Panel. But the code is not working. Following is the code I have written:

        var btn:Button = new Button;
        btn.width=90;
        btn.height=50;
        var hbox:HBox = new HBox;
        hbox.width=300;
        hbox.addChild(btn);
        this.titlePanel.addChild(hbox);

        where titlePanel is the name of the Panel. Can you please help me in this respect.

        Thanks,
        Nirmal Kumar Bhogadi

      • kumargandhi says:

        Hi,

        If your Panel is mx:Panel (Halo) you should do this inside the Panel, like, extend the Panel class and access the titleBar property of the Panel inside createChildren method and then add Button(‘s) to it, titleBar is a protected property of the Panel you cannot access it outside the Panel, hence this approach.
        it would look something like this
        protected override function createChildren():void
        {
        //Create the Buttons
        maximizeButton = new Button();
        titleBar.addChild(maximizeButton);
        }

        Or if your Panel is s:Panel (Spark) then you can create a skin for Panel and add buttons to title bar element, there are examples available on web.

        hope this helps.

        regards,
        kumar.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: