Is there an equivalent to LoadVars.send() in AS3 where I just send off variables without waiting for a response? I just send off the variables into cyberspace blindly, and I am happy that way. How do I do it? Or has it been removed for some security thingie in AS3?
+2
A:
You want to take a look at the following URLLoader, URLRequest and URLVariable documentation:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/URLVariables.html
Here's example usage directly from the documentation:
package {
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoader;
public class URLVariablesExample extends Sprite {
public function URLVariablesExample() {
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";
request.data = variables;
// navigateToUrl(request);
var loader:URLLoader = new URLLoader();
loader.load(request);
}
}
}
-BTW Yes, that's correct. You should be using URLLoader instead of navigateToURL. I mentioned it but I cut and paste from an example
Henry
2010-08-03 01:47:17
Thanks for helping. This solution opens up a new page/tab and if I specify another target like "_self" etc the page disappears. This only looks like it could work if you use the 'iframe hack' and put the results there.
Betamakz
2010-08-03 01:59:37
@Betamakz. Change the last line of Henry's code to: `var loader:URLLoader = new URLLoader(request); loader.load();`. It's the same as using `LoadVars` `sendAndLoad` but just not listening for a response.
Juan Pablo Califano
2010-08-03 02:11:42
@Henry. I took the liberty to change your code example to accomodate Betamakz's comment. Made no sense to basically replicate your answer just to change two lines. I hope you don't mind. I you do, though, feel free to roll back my edit. (+1 by the way)
Juan Pablo Califano
2010-08-03 02:24:17
+1 for @Juan's edit: [navigateToURL](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/package.html#navigateToURL%28%29) is for opening a new page in the browser: it "Opens or replaces a window in the application that contains the Flash Player container (usually a browser)"
Amarghosh
2010-08-03 04:01:53
Yes, that's correct. You should be using URLLoader instead of navigateToURL. I mentioned it but I cut and paste from an example
Henry
2010-08-05 19:18:31