个人总结flex各种用法【经典】
?个人总结flex各种用法【经典】
分类:?flex3
2009-10-30 18:56?
1341人阅读?
评论(6)?
收藏?
举报
//获得屏幕的分辨率 var?x:Number=Capabilities.screenResolutionX; ?y:Number=Capabilities.screenResolutionY; Alert.show("x="+x+"y="+y); 第二种方法 Alert.show(stage.fullScreenWidth+"=="+stage.fullScreenHeight); ? //获得stage(工作区)的宽、高 Alert.show(stage.stageWidth+"=="+stage.stageHeight); ? //读取xml文件 { var?urlrequest:URLRequest=new?URLRequest("file/stu.xml"); var?urlloader:URLLoader=new?URLLoader(urlrequest); urlloader.addEventListener(Event.COMPLETE,?completehandler); } ? private?function?completehandler(event:Event):void { var?xml:XML=new?XML(event.target.data); //?var?arr:Array=new?Array(xml); this.dg.dataProvider=xml.children(); this.tree.dataProvider=xml; this.cb.dataProvider=xml.children(); //?this.hlist.dataProvider=xml.children(); }
var?add:String=ExternalInterface.call("window.location.href.toString",1); Alert.show(add); ? //背景颜色不断变化 ?private?function?changeBG():void{ var?mytime:Timer=new?Timer(2000); mytime.addEventListener(TimerEvent.TIMER,changHandle); mytime.start(); ?} ?private?function?changHandle(e:TimerEvent):void{ this.setStyle("backgroundColor",Math.random()*?0xffffff); ?} ? //获得键盘按下的键的值 public?function?getCode():void { btn.addEventListener(KeyboardEvent.KEY_DOWN,?keyHandle); } ? function?keyHandle(event:KeyboardEvent):void Alert.show("你按下了:"?+?String.fromCharCode(event.charCode)); } //动态加载不同界面 import?commont.Two; ?commont.One; ?t:Two=new?Two(); ?o:One=?One(); private?function?showOne():void{ tw.removeAllChildren(); tw.addChild(o); } ?showTwo():tw.addChild(t); } //flex?绑定图片 [Bindable] Embed(source="img/1.jpg")] public??phone1:Class; ? //日期中文标题 <mx:DateChooser?id="dtchoose"?x="219"?y="83"?dayNames="[日,一二三四五六]"?monthNames="一月二月三月四月五月六月七月八月九月十月十一月十二月"?change="disDate()"?minYear="2007"/> //选择日期?dateChoose ?disDate():{ txtDate.text=fm.format(dtchoose.selectedDate.toLocaleDateString()); } ? //flex?中添加html标记 <mx:TextAreatext"?creationComplete="init()"?width="248"?height="59> <mx:htmlText> <![CDATA[ <input?type='file'/> <a?href="http://www.baidu.com">你哈!!!</a> ]]> </mx:htmlText> </mx:TextArea> ? //flex?带下划线的链接 this.lblLink.htmlText="<a?href='http://www.google.com'?target='_blank'>新?闻</a>"; ?rollOut="focusManager.activate()"?styleName="Label?creationComplete="link()"/> ? //flex?转向?URL Var?url:URLRequest=new?URLRequest(“http://www.google.cn”); navigateToURL(url,_self);//在本页打开 _blank);//在新的一页打开 ? //弹出对话框 PopUpManager.createPopUp(类(界面)的名称---------模式打开--------- ?ep:Main=??(); PopUpManager.addPopUp(ep,255); font-size: 11pt; font-weight: bold; ">true);//界面,打开窗口父类,是否模式 PopUpManager.centerPopUp(ep);//在父类窗口居中 ? //-----Alert的用法 ?test():void { ?glow:GlowFilter=?GlowFilter(); glow.color=StyleManager.getColorName("blue"//边框颜色 glow.strength=5; glow.alpha=0.8; ?alert:Alert=Alert.show("是否选择"提示alert.filters=[glow]; ?alertHandle(event:CloseEvent):if(event.detail==Alert.YES){ lbl.text=是; }else否<mx:Button6280"?label="Button"?click="test()"/> 37"?width="65lbl/> ? //flex?Combobox添加?–请选择- ?loadCB(){ ?arr:Array=?Array("-请选择-"for(?i:int=1;i<10;i++){ arr[i]=i; .cb.dataProvider=arr; } ? ? //combobox?选择的值和下标 ?selected():Alert.show(cb.selectedItem.toString()+下标:"+cb.selectedIndex); <mx:ComboBox194cb"?creationComplete="loadCB()"change="selected()"> ? //鼠标移动变大,Button加图片,变手型 72"?click="test()"?mouseMove="changBig()"?mouSEOut="changSmall()"?id="btn52"?icon="@Embed(source='img/3.jpg')?labelPlacement="bottom67"?useHandCursor="true"?buttonMode="/> ? ?changBig():.btn.scaleX=1.5; .btn.scaleY=1.5 ?changSmall():.btn.scaleX=1; .btn.scaleY=1; //flex?panel?拖动效果 <mx:Panel125192121"?layout="absolutepanel"?mouseDown="ondragStart(event)"?mouseUp="ondragStop(event)"</mx:Panel> ?ondragStart(event:MouseEvent):Panel(event.target).startDrag(); ?ondragStop(event:MouseEvent):Panel(event.target).stopDrag(); } ? //写入共享数据 share=SharedObject.getLocal("username"share.data.userName=txtUser.text; share.flush(); ? //读取共享数据 ?share:SharedObject=SharedObject.getLocal(); Alert.show(share.data.userName); ? ? ? ? ? ? ? //jsp/html文件嵌入到flex中(需要把flexiframe.swc放在项目的flex_libs下) ? Application标签内xmlns:code=http://code.google.com/p/flex-iframe/ ? <mx:HDividedBox010100%500?width="30%> ? 70%> <code:IFrame?id="frm"?source="file/万年历.html"?height="100%"?width="100%"/><!-这是最重要的-à </mx:HDividedBox> ? //检查使用的操作系统 ?checkOS():?os:String=Capabilities.os; tt.text=你的操作系统是:--"+os; //检查所使用的浏览器 ?checkPlay():?play:String=Capabilities.playerType; Alert.show(play); (play=="ActiveX"){ 你的浏览器是--IE""PlugIn"--Mozilla-Firefox"--其他//检查player的版本和使用的语言 ?other():?v:String=Capabilities.version; ?l:String=Capabilities.language; 你的flayer版本号:--"+v+ "/r/n你的语言是:+l; } ? //改变鼠标样式 ] "img/157.jpg")] ?cur:Class; ?initCursor(event:Event){ CursorManager.setCursor(cur); } ? //设置AdvancedDataGrid的表头竖线为空 headerSortSeparatorSkin="mx.skins.ProgrammaticSkin" ? ? ? ? ? //获得鼠标坐标 ?cx:Number=CursorManager.currentCursorXOffset; ?cy:Number=CursorManager.currentCursorYOffset; ?id:int=CursorManager.currentCursorID; "x:="+cx+"y:="+y+"id="+id); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |