flex 登录问题.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.atsog.commands::LoginCommand()[D:\flex cms\FyzzLiveCMS\src\com\atsog\commands\LoginCommand.as:29]
at com.atsog.controllers::RemoteController/handleUIEvent()[D:\flex cms\FyzzLiveCMS\src\com\atsog\controllers\RemoteController.as:106]
at FyzzLiveCMS/__popMediator_uiEvent()[D:\flex cms\FyzzLiveCMS\src\FyzzLiveCMS.mxml:60]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.atsog.mediators::PopUpMediator/eventHandler()[D:\flex cms\FyzzLiveCMS\src\com\atsog\mediators\PopUpMediator.as:117]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at com.atsog.views.panels::Login/authorise()[D:\flex cms\FyzzLiveCMS\src\com\atsog\views\panels\Login.mxml:63]
at com.atsog.views.panels::Login/__button1_click()[D:\flex cms\FyzzLiveCMS\src\com\atsog\views\panels\Login.mxml:78]
源代码是这样的.
login.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:mediators="com.atsog.mediators.*"
layout="absolute"
width="374"
height="184"
showCloseButton="false"
title="Login"
resizeEffect="Resize"
addedEffect="Fade"
creationComplete="this.addEventListener(KeyboardEvent.KEY_UP, keyHandler);"
borderColor="#E2E2E2" borderStyle="outset" backgroundColor="#E2E2E2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:states>
<mx:State name="passReminder">
<mx:RemoveChild target="{password}"/>
<mx:RemoveChild target="{label1}"/>
<mx:SetProperty target="{label2}" name="text" value="Enter Email"/>
<mx:RemoveChild target="{linkbutton1}"/>
<mx:SetProperty target="{button1}" name="y" value="45"/>
<mx:SetProperty name="height" value="118"/>
<!-- Changes event for 'submit' button to 'pass reminder' -->
<mx:SetEventHandler target="{button1}" name="click">
<mx:handler>trace('pass reminder sent');</mx:handler>
</mx:SetEventHandler>
<mx:AddChild position="lastChild">
<mx:LinkButton x="-5" y="49" label="Login" click="this.currentState=''" color="#0012FF" addedEffect="Fade" textAlign="left"/>
</mx:AddChild>
<mx:SetStyle target="{button1}" name="removedEffect" value="Blur"/>
<mx:SetStyle target="{button1}" name="addedEffect" value="Blur"/>
<mx:SetProperty target="{hrule1}" name="y" value="38"/>
</mx:State>
</mx:states>
<mx:Script>
<![CDATA[
import com.atsog.service.AMFService;
import mx.events.CloseEvent;
import com.atsog.events.UIEvent;
import com.atsog.model.vo.AMFValue ;
import com.atsog.controllers.RemoteController ;
public function keyHandler(evt:KeyboardEvent):void
{
if (evt.keyCode == 13)
{
removeEventListener(KeyboardEvent.KEY_UP, keyHandler);
authorise(username.text, password.text)
}
}
public function authorise(username:String, password:String):void
{
trace('authorising');
//试试这个语法
AMFValue.amfValue = DataCom.text.toString() ;
var payload:Object = {username:username, password:password};
new RemoteController().initAMFService() ;
dispatchEvent(new UIEvent(UIEvent.LOGIN, payload));
dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
}
]]>
</mx:Script>
<mx:Array id="data">
<mx:String>fyzzLive.cms</mx:String>
<mx:String>fyzzMusic.cms</mx:String>
<mx:String>fyzzInteractive.cms</mx:String>
<mx:String>fyzzProductions.cms</mx:String>
</mx:Array>
<mx:Label x="0" y="2" text="Username" id="label2"/>
<mx:Label x="0" y="29" text="Password" id="label1" addedEffect="Fade"/>
<mx:TextInput id="username" x="70" y="0" width="290" text="adam" tabIndex="1"/>
<mx:TextInput id="password" x="70" y="27" width="290" displayAsPassword="true" addedEffect="Fade" text="fethisaz" tabIndex="2"/>
<mx:Button x="274" y="101" label="Submit" click="authorise(username.text, password.text)" id="button1" tabIndex="4"/>
<mx:LinkButton x="0" y="108" label="Password Reminder" textAlign="left" color="#1200FF" id="linkbutton1" click="this.currentState='passReminder'" tabIndex="3"/>
<mx:HRule x="0" y="91" width="350" id="hrule1"/>
<mx:Label x="0" y="65" text="Data Center" width="81"/>
<mx:ComboBox x="70" y="63" width="199" id="DataCom" dataProvider="{data}"></mx:ComboBox>
</mx:TitleWindow>