Revision: 5213
Updated Code
at February 19, 2008 18:19 by chrisaiv
Updated Code
var requestVars:URLVariables = new URLVariables(); requestVars.object_name = "key1"; requestVars.cache = new Date().getTime(); var request:URLRequest = new URLRequest(); request.url = "http://localhost:3000/videos/find_path/"; request.method = URLRequestMethod.GET; request.data = requestVars; for (var prop:String in requestVars) { trace("Sent " + prop + " as: " + requestVars[prop]); } var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, loaderCompleteHandler); loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); try { loader.load(request); } catch (error:Error) { trace("Unable to load URL"); } function loaderCompleteHandler(e:Event):void { var variables:URLVariables = new URLVariables( e.target.data ); if(variables.success) { trace(variables.path); } } function httpStatusHandler (e:Event):void { //trace("httpStatusHandler:" + e); } function securityErrorHandler (e:Event):void { trace("securityErrorHandler:" + e); } function ioErrorHandler(e:Event):void { trace("ioErrorHandler: " + e); }
Revision: 5212
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 19, 2008 18:13 by chrisaiv
Initial Code
var requestVars:URLVariables = new URLVariables(); requestVars.object_name = "key1"; requestVars.cache = new Date().getTime(); var request:URLRequest = new URLRequest(); request.url = "http://localhost:3000/videos/find_path/"; request.method = URLRequestMethod.GET; request.data = requestVars; for (var prop:String in requestVars) { trace("Sent " + prop + " as: " + requestVars[prop]); } var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, loaderCompleteHandler); try { loader.load(request); } catch (error:Error) { trace("Unable to load URL"); } function loaderCompleteHandler(e:Event):void { var variables:URLVariables = new URLVariables( e.target.data ); if(variables.success) { trace(variables.path); } }
Initial URL
Initial Description
I needed a way to do a Database lookup using GET. This simple example sends a GET requests and shows how to collect a response that would look like this "success=true&path=xyz.flv"
Initial Title
AS3: Sending and Recieving Data using a GET Request
Initial Tags
Initial Language
ActionScript 3