Sending Variables and Handling a Returned Result
package {
import flash.display.*;
import flash.text.*;
import flash.events.*
import flash.net.*;
public class Main extends Sprite {
private var _output:TextField = new TextField();
public function Main ( ) {
_output.width = stage.stageWidth;
_output.height = stage.stageHeight;
addChild( _output );
var request:URLRequest = new URLRequest( "test.cfm" );
var variables:URLVariables = new URLVariables( );
variables.method = "getProductDetail"
variables.productId = 2;
request.data = variables;
var loader:URLLoader = new URLLoader( );
// loader.dataFormat = DataFormat.VARIABLES;
loader.addEventListener( Event.COMPLETE, handleComplete );
loader.load( request );
}
private function handleComplete( event:Event ):void {
var loader:URLLoader = URLLoader( event.target );
_output.text = "Name: " + loader.data.name + "\n"
+ "Description: " + loader.data.description;
}
}
}
Related examples in the same category