Flex学习笔记
发布时间:2020-12-15 04:02:10 所属栏目:百科 来源:网络整理
导读:5.集合过滤 ?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="appComplete()"mx:ArrayCollection id="myColl"mx:sourcemx:StringfLASH/mx:Stringmx:StringfLASH 111/
5.集合过滤<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="appComplete()"> <mx:ArrayCollection id="myColl"> <mx:source> <mx:String>fLASH</mx:String> <mx:String>fLASH 111</mx:String> <mx:String>fLASH 222</mx:String> </mx:source> </mx:ArrayCollection> <mx:TitleWindow x="283" y="54" width="326" height="332" layout="absolute" title="过滤"> <mx:List dataProvider="{myColl}" x="59" y="39" height="179" width="175"></mx:List> <mx:Button x="111" y="248" label="开始过滤" click="test(event)" /> </mx:TitleWindow> <mx:Script> <![CDATA[ import mx.controls.Alert; var i:int = 0; private function test(e:MouseEvent):void { myColl.refresh(); } private function appComplete():void { myColl.filterFunction = filter222; //循环 } private function filter222(item:String):Boolean { Alert.show(i + ""); i++; return (item.search("fLASH 222") == -1); } ]]> </mx:Script> </mx:Application>4.集合<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="appComplete()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; function appComplete():void { //创建一个集合 var d:ArrayCollection = new ArrayCollection(); //add d.addItemAt("qaz",0); d.addItem("1"); d.addItem("2"); d.addItem("3"); Alert.show("test:" + d.getItemAt(0)); //迭代 for each (var item:String in d) { Alert.show(item); } } ]]> </mx:Script> </mx:Application>3.Bindable<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ //运用绑定 可以将控件上面的值进行动态的改变 没有绑定则不能动态的改变 [Bindable] public var max:Number = 15; [Bindable] public var min:Number = 5; ]]> </mx:Script> <mx:Label text="{max }" x="155" y="118"/> <mx:Label text="{min }" x="368" y="118"/> <mx:Button click="max=20;min=10" /> </mx:Application>2.鼠标双击<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Button x="251" y="219" label="鼠标双击定义事件" height="47" id="my_button" click="clickDouble(event)"/> <mx:Script> <![CDATA[ import mx.controls.Alert; private var delay:uint = 300;//定义鼠标延迟时间 private var firstClick:uint; private var lastClick:uint; function clickDouble(e:MouseEvent):void { //鼠标双击就触发该事件 if(firstClick == 0) { firstClick = getTimer(); } else { lastClick = getTimer(); if((lastClick - firstClick) < delay) { //...... Alert.show(firstClick + "双击"); } } firstClick = getTimer(); } ]]> </mx:Script> </mx:Application> <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="appComplete()"> <mx:Button x="311" y="55" label="点击我哦" width="108" height="38" id="my_button"/> <mx:Script> <![CDATA[ import mx.controls.Alert; //事件触发 //1. var myClick:Function = function(e:MouseEvent) { //鼠标点击事件 Alert.show("你点击了我!"); } //2.监听事件 function appComplete():void { //Alert.show("ss");绑定点击事件 my_button.addEventListener("click",myClick); } ]]> </mx:Script> </mx:Application> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |