flex 发Java数据
写道
package
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class SendURL extends Sprite
{
public function SendURL()
{
//创建请求
var request:URLRequest = new URLRequest( "http://localhost:8081/cqaplat/flexcontroller/getdata" );
//创建发送参数
var variables:URLVariables = new URLVariables( );
variables.method = "getProductDetail"
variables.productId = 2;
request.data = variables;
//为接受返回参数做准备
// 创建URLLoader实例
var loader:URLLoader = new URLLoader( );
// 定义事件处理函数
loader.addEventListener( Event.COMPLETE, handleComplete );
// 设置读取的是URL-编码变量
loader.dataFormat = URLLoaderDataFormat.TEXT;;
// 尝试读取数据
loader.load( request );
}
private function handleComplete( event:Event ):void {
var loader:URLLoader = URLLoader( event.target );
trace( "someText = " + loader.data );
}
}
}
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class SendURL extends Sprite
{
public function SendURL()
{
//创建请求
var request:URLRequest = new URLRequest( "http://localhost:8081/cqaplat/flexcontroller/getdata" );
//创建发送参数
var variables:URLVariables = new URLVariables( );
variables.method = "getProductDetail"
variables.productId = 2;
request.data = variables;
//为接受返回参数做准备
// 创建URLLoader实例
var loader:URLLoader = new URLLoader( );
// 定义事件处理函数
loader.addEventListener( Event.COMPLETE, handleComplete );
// 设置读取的是URL-编码变量
loader.dataFormat = URLLoaderDataFormat.TEXT;;
// 尝试读取数据
loader.load( request );
}
private function handleComplete( event:Event ):void {
var loader:URLLoader = URLLoader( event.target );
trace( "someText = " + loader.data );
}
}
}