Make object as Bindable in Flex/AIR

Try use ObjectProxy instead of Object.

[Bindable]
private var registerProxy:ObjectProxy = new ObjectProxy();

public function setDP():void{
	
	registerProxy.firstName = 'Raja';
	registerProxy.middleName ='Kumar'
	registerProxy.lastName = 'King'
	registerProxy.email = 'rajaj@sybrant.com';
	registerProxy.password = 'pwd';
	registerProxy.confirmPassword = 'pwd';
}

public function dataUpdateHandler(event:Event, property:String, typeString:String):void
{
	if(!registerProxy.hasOwnProperty(property))
	{
		Alert.show('registerProxy doesn\'t contains property' + property);
		return;
	}
	
	switch (typeString.toLowerCase())
	{
		case 'textinput':registerProxy[property] =((event.currentTarget as TextInput).text);break;
		case 'textarea':registerProxy[property] =((event.currentTarget as TextArea).text);break;
		case 'dropdownlist':registerProxy[property] =((event.currentTarget as DropDownList).selectedItem);break;
		case 'checkbox':registerProxy[property] =((event.currentTarget as CheckBox).selected.toString());break;
		case 'numstepper':registerProxy[property] =((event.currentTarget as NumericStepper).value.toString());break;
	}
}

<s:Form>
	<s:FormItem label="First Name" skinClass="MyFormItemSkin">
		<s:TextInput text="{registerProxy.firstName}" change="dataUpdateHandler(event,'firstName','textinput')"/>
	</s:FormItem>
	<s:FormItem label="Middle Name" skinClass="MyFormItemSkin">
		<s:TextInput text="{registerProxy.middleName}" change="dataUpdateHandler(event,'middleName','textinput')"/>
	</s:FormItem>
	<s:FormItem label="Last Name" skinClass="MyFormItemSkin">
		<s:TextInput text="{registerProxy.lastName}" change="dataUpdateHandler(event,'lastName','textinput')"/>
		<s:TextInput text="{registerProxy.email}" change="dataUpdateHandler(event,'email','textinput')"/>
	</s:FormItem>
	<s:FormItem label="Password">
		<s:TextInput text="{registerProxy.password}" change="dataUpdateHandler(event,'password','textinput')"/>
	</s:FormItem>
</s:Form>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s