Using addElement() method to add Button to Panel : Panel « Container « Flex






Using addElement() method to add Button to Panel

Using addElement() method to add Button to Panel
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- optimize/CreateStyledButton.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
    creationComplete="initApp(event)">
    <fx:Script> 
        import spark.components.Button; 
        public function initApp(e:Event):void { 
            var b:Button = new Button(); 
            b.label="Click Me"; 
            b.setStyle("color", 0x00CCFF); 
            panel1.addElement(b); 
        } 
      </fx:Script>
    <s:Panel id="panel1" />
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Adding Label to PanelAdding Label to Panel
2.Set Title for PanelSet Title for Panel
3.Panel with Padding
4.Padding setting for PanelPadding setting for Panel
5.Panel containerPanel container
6.Add Label to Panel
7.hidden while the Panel containers resizehidden while the Panel containers resize
8.Panel Scroll PolicyPanel Scroll Policy
9.Use SetProperty to change panel property valueUse SetProperty to change panel property value
10.Use Panel to hold controlsUse Panel to hold controls
11.Add labels to your PanelsAdd labels to your Panels
12. tag defines a Panel container<s:Panel> tag defines a Panel container
13.Panel with titlePanel with title
14.Set Panel width and height to 100%Set Panel width and height to 100%
15.Panel creationComplete and initializePanel creationComplete and initialize
16.Resize Panel with animationResize Panel with animation
17.Enlarge panel to 100% width and 100% heightEnlarge panel to 100% width and 100% height
18.Put controls onto a PanelPut controls onto a Panel
19.Add three Canvas containers to a Panel container, each Canvas having a different colorAdd three Canvas containers to a Panel container, each Canvas having a different color
20.To anchor the Panel perfectly in the center, set both fields to 0To anchor the Panel perfectly in the center, set both fields to 0
21.Replace the Panel containers with Form and FormItem containersReplace the Panel containers with Form and FormItem containers
22.Build Form with PanelBuild Form with Panel
23.Define a Panel container that contains a form as the top-level container in your application.Define a Panel container that contains a form as the top-level container in your application.
24.Panel container provides you with a mechanism for including a title bar, as in a standard GUI window.Panel container provides you with a mechanism for including a title bar, as in a standard GUI window.
25.Set Panel's creationPolicy property to auto, the default valueSet Panel's creationPolicy property to auto, the default value
26.Complex MultiPanelComplex MultiPanel
27.Two Creation PoliciesTwo Creation Policies