//显示对象容器中显示列表的缩进式 trace() 输出 function traceDisplayList(container:DisplayObjectContainer, indentString:String = ""):void { var child:DisplayObject; for (var i:uint=0; i < container.numChildren; i++) { child=container.getChildAt(i); trace(indentString, child, child.name); if (container.getChildAt(i) is DisplayObjectContainer) { traceDisplayList(DisplayObjectContainer(child), indentString + " "); } } } //替换字符串 var str:String="here is some info '{0}' and {1}"; trace(mx.utils.StringUtil.substitute(str, 15.4, true)); // "here is some info '15.4' and true" //事件调度 addEventListener("complete", completeHandler); function completeHandler(event:Event):void { trace(event); } dispatchEvent(new Event("complete")); //数组对象深复制 import flash.utils.ByteArray; function clone(source:Object):* { var myBA:ByteArray = new ByteArray(); myBA.writeObject(source); myBA.position = 0; return(myBA.readObject()); } //显示对象容器中显示列表的缩进式 trace() 输出 function traceDisplayList(container:DisplayObjectContainer,indentString:String = ""):void { var child:DisplayObject; for (var i:uint=0; i < container.numChildren; i++) { child = container.getChildAt(i); trace(indentString, child, child.name); if (container.getChildAt(i) is DisplayObjectContainer) { traceDisplayList(DisplayObjectContainer(child), indentString + " "); } } } //元素类型int,ture表示数组固定长度为5不可更改 var square_commands:Vector. = new Vector.(5,true); //杂点效果,草地效果 var bd:BitmapData = new BitmapData(250, 250,false, 0xff000000); bd.noise(500, 0, 255, BitmapDataChannel.GREEN,false); var img:Bitmap = new Bitmap(bd); addChild(img); //视频播放 var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.client = { "onMetaData":function (infoObject:Object):void{trace("metadata");}, "onCuePoint":function (infoObject:Object):void{trace("cuepoint");} } ns.play("video.flv"); var vid:Video = new Video(); vid.attachNetStream(ns); addChild(vid); //双点号(..),又称为后裔访问符(the descendent accessor),访问当前元素的所有子元素 //双冒号(::),命名空间名称限定符(双冒号)name qualifier punctuator //阻止再冒泡 function p2(event:MouseEvent):void { trace("t2 click"); event.stopPropagation(); } t1.t2.addEventListener(MouseEvent.CLICK, p2); //ComboBox 组件 var aCb:ComboBox = new ComboBox(); aCb.dropdownWidth = 210; //下拉列表宽度 aCb.prompt = "San Francisco Area Universities"; //提示信息 aCb.addEventListener(Event.CHANGE, changeHandler); function changeHandler(event:Event):void { trace( ComboBox(event.target)==aCb ) //true aCb.selectedIndex = -1; //显示提示 prompt } //修改舞台上组件的样式 import fl.managers.StyleManager; import fl.controls.Button; var tf:TextFormat = new TextFormat(); tf.color = 0xFF0000; StyleManager.setComponentStyle(Button, "textFormat", tf); //修改舞台上所有button组件的样式 StyleManager.setStyle("textFormat", tf); //修改舞台上所有组件的样式