I am facing an issue in retrieving value in ActionScript from TitleWindow mxml. Following is the 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>
Following is ActionScript code snippet
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");
}
}
Following is MainView.mxml showing the inclusion of UpdateRelease.mxml
<s:VGroup width="100%" height="100%" >
<mx:ViewStack id="vs">
<views:UpdateRelease id="updateReleaseValueView" width="100%" height="100%"/>
</mx:ViewStack>
</s:VGroup>
The issue is in the following statement in ActionScript file.
I found that the following statements don’t work as expected. The execution fails at the first one below. Can someone point out what is the mistake here?
obj["release"] = this.mainView.updateReleaseValueView.releaseName.text;
obj["releaseDate"] = this.mainView.updateReleaseValueView.releaseDate.text;
obj["otherInfo"] = this.mainView.updateReleaseValueView.relOtherInfo.text;
I couldn’t figure out the problem yet. But I found a different way to get around this. I declared some variables in the parent mxml (from where I launch the popup) and set those variables with values from pop-up when “OK” button click is handled. It works now. I don’t think this is a good idea, but I am going to ahead with this approach until I figure out the problem with the above code.
And, I thank those who spent their time reading the question to find the problem 🙂