Send text message to a Php server
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private function onKeyDown( event:KeyboardEvent ) : void {
if ( event.keyCode == Keyboard.ENTER ) {
var url:String = "http://localhost/add.php?user="+escape(user.text)+"&message="+escape(msg.text);
var htMessages:HTTPService = new HTTPService();
htMessages.url = url;
htMessages.send();
msg.text = '';
}
}
</mx:Script>
<mx:Form width="100%">
<mx:FormItem label="User name" width="100%">
<mx:TextInput id="user" width="100%" text="Jack" />
</mx:FormItem>
<mx:FormItem label="Message" width="100%">
<mx:TextInput id="msg" width="100%" keyDown="onKeyDown(event);" />
</mx:FormItem>
</mx:Form>
</mx:Application>
Related examples in the same category