<?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" minWidth="955" minHeight="600">
<fx:Style source="test.css"
/>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
protected function buttion_clickHandler(event:MouseEvent):void
{
var mm=parseInt(txtName.text);
var dd=parseInt(txtPswd.text);
var sumInts:int=addInts(dd,mm);
lblResult.text="结果等于"+sumInts;
}
private function addInts( value1:int,value2:int):int
{
var sum:int=value1+value2;
return sum;
}
]]>
</fx:Script>
<s:Panel x="698" y="241" width="522" height="278" id="pLgion" title="地图管理系统" color="#020202" fontStyle="italic" textAlign="center" fontFamily="中易宋体" enabled="true">
<s:Label x="158" y="58" text="用户名:" id="lbluserName" textAlign="center"/>
<s:Label x="160" y="110" text="密 码:" id="lblPsd" textAlign="center"/>
<s:TextInput x="214" y="51" textAlign="left" width="140" id="txtName"/>
<s:TextInput x="216" y="104" textAlign="left" width="138" id="txtPswd"/>
<s:Button x="186" y="157" label="登陆" click="buttion_clickHandler(event)"/>
<s:Button x="281" y="157" label="注册"/>
<s:Label x="214" y="203" id="lblResult"/>
</s:Panel>
</s:Application>
注释:这里面要用到的一个知识点就是类型转换(文本类型转换成整型)parseInt(txtName.text);和触发事件click="buttion_clickHandler(event)"