[img]http://dl.iteye.com/upload/picture/pic/116125/f7fdc1fe-448d-387d-a69b-4667b523df7a.png[/img]
<?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" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.containers.Panel;
import mx.events.CloseEvent;
import mx.controls.Alert;
var verCode:String;
var card_number:String;
protected function init():void{
verCode=Math.round(Math.random()*10000)+"";
verifyCode.text=verCode;
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
var userCode:String=uCode.text;
if(userCode==verCode){
card_number=card_num.text;
moPanel.title=moPanel.title+" "+card_number;
loginPanel.removeAllElements();
moPanel.removeElementAt(1);
mainPanel.enabled=true;
return;
}else{
Alert.show("验证失败!");
init();
}
}
protected function titlewindow1_closeHandler(event:CloseEvent):void
{
// TODO Auto-generated method stub
loginPanel.removeAllElements();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Panel id="moPanel" x="0" y="0" width="100%" height="100%" title="XMercury System 1.0.0">
<s:Panel id="mainPanel" x="0" y="0" width="100%" height="100%" enabled="false">
<mx:TabNavigator x="0" y="0" width="100%" height="100%">
<s:NavigatorContent width="100%" height="100%" label="账户信息">
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" label="网上充值">
</s:NavigatorContent>
</mx:TabNavigator>
</s:Panel>
<s:BorderContainer id="loginPanel" x="0" y="0" width="100%" height="100%" backgroundAlpha="0.1"
backgroundColor="#D4D4D4" borderAlpha="0.73" borderVisible="false">
<s:layout>
<s:VerticalLayout horizontalAlign="center" paddingTop="150"/>
</s:layout>
<s:TitleWindow width="250" height="200" backgroundColor="#EFEFEF"
close="titlewindow1_closeHandler(event)" enabled="true" title="会员登陆">
<s:Button x="162" y="132" label="登陆" click="button1_clickHandler(event)"
focusColor="#70B2EE"/>
<s:TextInput id="card_num" x="80" y="21"/>
<s:TextInput x="80" y="58" displayAsPassword="true"/>
<s:Label x="30" y="27" text="卡号"/>
<s:Label x="30" y="64" text="密码"/>
<s:Label x="30" y="102" text="验证"/>
<s:TextInput id="uCode" x="80" y="94" width="60"/>
<s:Label id="verifyCode" x="163" y="99" backgroundColor="#70B2EE" color="#155693"
fontSize="16" text="0000"/>
</s:TitleWindow>
</s:BorderContainer>
</s:Panel>
</s:Application>
package com.user.command
{
import com.adobe.cairngorm.commands.ICommand;
import com.adobe.cairngorm.control.CairngormEvent;
import com.user.event.UserEvent;
import com.user.service.UserProxy;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.core.Application;
import mx.rpc.IResponder;
public class UserCommand implements ICommand, IResponder
{
public function UserCommand()
{
}
//执行调用
public function execute(event:CairngormEvent):void
{
var userEvent:UserEvent=UserEvent(event);
var userService:UserProxy=new UserProxy(this);
userService.login(userEvent.username,userEvent.password);
}
//更新模型
public function result(data:Object):void
{
var message:String=data.result as String;
Application.application.mainContainer.removeElement(Application.application.loginPanel);
Application.application.main_.message_label.text=message;
}
public function fault(info:Object):void
{
Alert.show("Fail Error ");
}
}
}