鄙人flex小试身手,做了一个计算器
发布时间:2020-12-15 04:12:03 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="528" height="285" minWidth="955" minHeight="600"fx:Decl
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="528" height="285" minWidth="955" minHeight="600"> <fx:Declarations> <!--<s:RemoteObject id="obj" destination="product"/>--> </fx:Declarations> <fx:Style> #calc_label{ fontSize:22; fontWeight:bold; fontFamily:"宋体"; color:#00e3e3; } </fx:Style> <fx:Script> <![CDATA[ import flashx.textLayout.formats.Float; import mx.collections.ArrayCollection; import mx.controls.Alert; [Bindable] public var cards:ArrayCollection = new ArrayCollection( [ {label:"加",data:1},{label:"减",data:2},{label:"乘",data:3},{label:"除",data:4}] ); protected function button1_clickHandler(event:MouseEvent):void { // opr.selectedItem var oper:int=opr.selectedItem.data; var ii1:Number,ii2:Number; var result:String; try{ ii1=parseFloat(i1.text); ii2=parseFloat(i2.text); }catch(e:Error){ Alert.show(e.message+"出错了"); return; } if(isNaN(ii1)||isNaN(ii2)){ Alert.show("输入不合法"); return; } switch(oper) { case 1: { result=(ii1+ii2)+""; break; } case 2: { result=(ii1-ii2)+""; break; } case 3: { result=(ii1*ii2)+""; break; } case 4: { if(ii2==0){ Alert.show("除数不合法"); i2.text=""; return; } result=(ii1*1.0/ii2)+""; break; } } resultL.text=result; } ]]> </fx:Script> <s:Label x="67" y="62" width="230" height="36" text="计算器" id="calc_label"/> <s:TextInput id="i1" x="67" y="104" width="65"/> <s:TextInput id="i2" x="224" y="102" width="70"/> <s:Label x="325" y="104" width="173" height="22" id="resultL" /> <s:Button id="result" x="185" y="165" label="计算结果" click="button1_clickHandler(event)"/> <s:ComboBox id="opr" x="152" y="103" width="51" dataProvider="{cards}" selectedIndex="0"/> </s:Application>
? ? as3编译后swf文件下载地址:http://download.csdn.net/detail/yx511500623/5809291 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |