Hi,
I am relatively new to flex.I have a small problem.i have main mxml
file called Layout.mxml where i am calling component called register
which is separate mxml file.
I am getting following error when click register button to process my
function
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at components::Register/handleClickEvent()
at components::Register/___Register_Button1_click()
This is my Register file.
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" color="#0B113C"
alpha="1.0">
<mx:Script>
<![CDATA[
import model.Account;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import flash.events.Event;
[Bindable]
public var createflag:Boolean;
[Bindable]
public var userName:String;
[Bindable]
public var passWord:String;
[Bindable]
public var name1:String;
[Bindable]
public var companyName:String;
[Bindable]
public var address1:String;
[Bindable]
public var address2:String;
[Bindable]
public var city:String;
[Bindable]
public var state:String;
[Bindable]
public var country:String;
[Bindable]
public var accountType:String;
[Bindable]
public var promotionCode:String;
[Bindable]
public var phone:String;
private function validRegister(event:ResultEvent):void{
createflag = event.result as Boolean;
if(createflag){
Alert.show("Registration completed.Login with username and
password");
}
else{
Alert.show("Problem During Registration");
}
}
[Bindable]
public var account:Account
private function handleClickEvent(eventObj:Event):void{
account.userName=userName;
account.passWord=passWord;
account.address1=address1;
account.address2=address2;
account.city=city;
account.company=companyName;
account.country=country;
account.phoneNumber=phone;
account.accountEmail="";
srv.create(account);
}
]]>
</mx:Script>
<mx:Form borderColor="#9CC1DA" color="#215FEE"
backgroundColor="#EDF6F7" borderStyle="solid" cornerRadius="20"
id="RegisterId" alpha="1.0" borderThickness="20" label="Register">
<mx:FormHeading label="Register Here"/>
<mx:FormItem label="UserName">
<mx:TextInput text="{userName}"/>
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput text="{passWord}"/>
</mx:FormItem>
<mx:FormItem label="Confirm Password">
<mx:TextInput/>
</mx:FormItem>
<mx:FormItem label="Name">
<mx:TextInput text="{name1}"/>
</mx:FormItem>
<mx:FormItem label="Company Name">
<mx:TextInput text="{companyName}"/>
</mx:FormItem>
<mx:FormItem label="Address1">
<mx:TextInput text="{address1}"/>
</mx:FormItem>
<mx:FormItem label="Address2">
<mx:TextInput text="{address2}"/>
</mx:FormItem>
<mx:FormItem label="City">
<mx:TextInput text="{city}"/>
</mx:FormItem>
<mx:FormItem label="State">
<mx:ComboBox></mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Country">
<mx:ComboBox></mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Phone">
<mx:TextInput text="{phone}"/>
</mx:FormItem>
<mx:FormItem label="Account Type">
<mx:ComboBox></mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Promotion Code">
<mx:TextInput text="{promotionCode}" />
<mx:Button label="Register" click =
"handleClickEvent(event);"/>
</mx:FormItem>
</mx:Form>
<mx:RemoteObject id="srv" destination="rec">
<mx:method name="create" result="validRegister(event)"/>
</mx:RemoteObject>
</mx:VBox>
///This is my component instantiation code in main file.
<components:Register id="register" x="250" y="600"/>
Thanks is advance.