Hello,
I have couple of questions on httpservice and combobox.
1. I have a array collection of value objects, I want to send the data in these value objects over httpservices. My code for httpservice is:
<mx:HTTPService
id="createAccount" url="http://localhost/createAccount.php" method="POST" result="accountResult(event)">
<mx:request xmlns=""><usernames>
</usernames>
</mx:request>
</mx:HTTPService>
If the data is directly from controls its not a problem but if its from a value object how do i send the data in actionscripts??.
2. I want to know how to populate the combobox dynamically.. for example, when I press a button, i want to populate the combobox with a text retrieved from an edit box and i want to select that item. I checked combobox class, it doesnt have additem funcion in it..
Any help would be appreciated.
Thanks,
Bharani
Solved! Go to Solution.
Views
Replies
Total Likes
If this post answers your question or helps, please mark it as such.
1) Maybe just send the data using myVO.toString(), or else use JSON to encode the data. These links may help:
http://www.switchonthecode.com/tutorials/flex-php-tutorial-transmitting-data-using-json
http://www.switchonthecode.com/tutorials/using-flex-php-and-json-to-modify-a-mysql-database
http://www.switchonthecode.com/tutorials/flex-php-json-mysql-advanced-updating
2) Add to the ComboBox dataProvider. With data driver controls, you almost always want to operate on the dataProvider to affect what appears in the control.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var ac:ArrayCollection = new ArrayCollection([
"one", "two", "three"
]);
private function clickFunc():void{
if(txt.text != ""){
ac.addItemAt(txt.text, 0);
cbx.selectedIndex=0;
}
}
]]>
</mx:Script>
<mx:ComboBox id="cbx" dataProvider="{ac}"/>
<mx:TextInput id="txt"/>
<mx:Button label="Add Item" click="clickFunc()"/>
</mx:Application>
Views
Replies
Total Likes
If this post answers your question or helps, please mark it as such.
1) Maybe just send the data using myVO.toString(), or else use JSON to encode the data. These links may help:
http://www.switchonthecode.com/tutorials/flex-php-tutorial-transmitting-data-using-json
http://www.switchonthecode.com/tutorials/using-flex-php-and-json-to-modify-a-mysql-database
http://www.switchonthecode.com/tutorials/flex-php-json-mysql-advanced-updating
2) Add to the ComboBox dataProvider. With data driver controls, you almost always want to operate on the dataProvider to affect what appears in the control.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var ac:ArrayCollection = new ArrayCollection([
"one", "two", "three"
]);
private function clickFunc():void{
if(txt.text != ""){
ac.addItemAt(txt.text, 0);
cbx.selectedIndex=0;
}
}
]]>
</mx:Script>
<mx:ComboBox id="cbx" dataProvider="{ac}"/>
<mx:TextInput id="txt"/>
<mx:Button label="Add Item" click="clickFunc()"/>
</mx:Application>
Views
Replies
Total Likes
Thanks for your reply.. it was very helpful.. I have a question again.. my question was to send data in value objects to the server. So here is my code
private function CreateAccount():
void
{
var httpConn:HTTPService = new HTTPService("http://localhost/createAccount.php");
httpConn.request.fullname = FullNameEdit.text;
httpConn.request.numusers = userList.length;
for(var i:Number = 0; i < userList.length; i++)
{
var user:UserDetails = userList[i];
httpConn.request.username[i] = user.userName;
}
httpConn.send();
What I want is the event that is sent when the post is sent and a reply comes back from the webserver. I wanna do this from the actionscript. is there a way to do it??
Thanks,
Bharani
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies