我在从 TitleWindow mxml 检索 ActionScript 中的值时遇到问题。以下是 UpdateRelease.mxml
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
title="Title Window" x="168" y="86">
<mx:Script>
<![CDATA[
import com.paul.data.ReleaseVO;
import mx.controls.Alert;
import mx.controls.Text;
import mx.managers.PopUpManager;
[Bindable]
public var i_ReleaseVO:ReleaseVO = null;
// Event handler for the OK button.
protected function updateReleaseData(): void {
if(releaseName.text == '')
Alert.show("Release Name cannot be null");
else if(releaseDate.text == '')
Alert.show('Release Date cannot be null');
else
(parentApplication as Main).mainScreen.updateReleaseEvent();
}
]]>
</mx:Script>
<mx:Canvas>
<mx:VBox>
<mx:HBox>
<mx:Label text="Release Name"/>
<mx:TextInput id="releaseName" width="100%" text="{i_ReleaseVO.release}"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Release Date"/>
<mx:DateField id="releaseDate" width="100%" selectedDate="{DateField.stringToDate(i_ReleaseVO.relDate, 'YYYY/MM/DD')}"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Other Info"/>
<mx:TextInput id="relOtherInfo" width="100%" text="{i_ReleaseVO.otherInfo}"/>
</mx:HBox>
<mx:HBox>
<mx:Button label="OK" click="updateReleaseData();"/>
<mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
以下是 ActionScript 代码片段
public function updateReleaseEventHandler( pEvent:Event ): void {
if(i_RequestServiceProxy != null) {
var i_RequestParams:Object ={};
i_HttpXMLRequest = new HttpXMLRequest();
var obj:Object = new Object();
obj["release"] = this.mainView.updateReleaseValueView.releaseName.text;
obj["releaseDate"] = this.mainView.updateReleaseValueView.releaseDate.text;
obj["otherInfo"] = this.mainView.updateReleaseValueView.relOtherInfo.text;
i_RequestParams = i_HttpXMLRequest.getUpdateReleaseParams( obj );
i_RequestServiceProxy.updateRelease( i_RequestParams );
} else {
Alert.show("i_RequestServiceProxy is NULL");
}
}
以下是 MainView.mxml 显示包含 UpdateRelease.mxml
<s:VGroup width="100%" height="100%" >
<mx:ViewStack id="vs">
<views:UpdateRelease id="updateReleaseValueView" width="100%" height="100%"/>
</mx:ViewStack>
</s:VGroup>
问题出在 ActionScript 文件中的以下语句中。我发现以下语句没有按预期工作。执行在下面的第一个失败。有人可以指出这里的错误是什么吗?
obj["release"] = this.mainView.updateReleaseValueView.releaseName.text;
obj["releaseDate"] = this.mainView.updateReleaseValueView.releaseDate.text;
obj["otherInfo"] = this.mainView.updateReleaseValueView.relOtherInfo.text;