The following example shows how you can create a simple Panel container with a nested ControlBar container in Flex using ActionScript
<?
xml version="1.0" encoding="utf-8"
?>
<!-- http://blog.flexexamples.com/2008/02/25/creating-a-controlbar-container-in-flex-using-actionscript/ -->
< mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml"
layout ="vertical"
verticalAlign ="middle"
backgroundColor ="white"
creationComplete ="init();" >
< mx:Script >
<![CDATA[
import mx.controls.Button;
import mx.controls.Text;
import mx.containers.ControlBar;
import mx.containers.Panel;
private var panel:Panel;
private var cBar:ControlBar
private var txt:Text;
private var btn:Button;
private function init():void {
txt = new Text();
txt.text = "The quick brown fox jumped over the lazy dog.";
txt.percentWidth = 100;
btn = new Button();
btn.label = "Button";
cBar = new ControlBar();
cBar.addChild(btn);
panel = new Panel();
panel.title = "Panel title";
panel.status = "status";
panel.width = 160;
panel.height = 140;
panel.addChild(txt);
panel.addChild(cBar);
addChild(panel);
}
]]>
</ mx:Script >
</ mx:Application >
<!-- http://blog.flexexamples.com/2008/02/25/creating-a-controlbar-container-in-flex-using-actionscript/ -->
< mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml"
layout ="vertical"
verticalAlign ="middle"
backgroundColor ="white"
creationComplete ="init();" >
< mx:Script >
<![CDATA[
import mx.controls.Button;
import mx.controls.Text;
import mx.containers.ControlBar;
import mx.containers.Panel;
private var panel:Panel;
private var cBar:ControlBar
private var txt:Text;
private var btn:Button;
private function init():void {
txt = new Text();
txt.text = "The quick brown fox jumped over the lazy dog.";
txt.percentWidth = 100;
btn = new Button();
btn.label = "Button";
cBar = new ControlBar();
cBar.addChild(btn);
panel = new Panel();
panel.title = "Panel title";
panel.status = "status";
panel.width = 160;
panel.height = 140;
panel.addChild(txt);
panel.addChild(cBar);
addChild(panel);
}
]]>
</ mx:Script >
</ mx:Application >
本文转自 OldHawk 博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2008/02/28/1085132.html
,如需转载请自行联系原作者