Posted on March 16, 2004 by Grant SkinnerHaving extended XML into an ActionScript 2.0 friendly class (see: The ultimate AS2 XML solution!), I didn’t feel it was appropriate to neglect poor old LoadVars. Sure LoadVars is getting a little old and rusty, but its still useful at times, and it sure would be nice to have it in an AS2 friendly format. // import the class: import com.gskinner.net.LoadVars2; myLV:LoadVars2 = new LoadVars2(); // subscribe to its load event: myLV.addEventListener("load",this); // add some data to send: myLV.username = "bob"; myLV.password = "555123"; // set the timeout period to 5 seconds (default is 7s): myLV.timeout = 5000; // this should timeout after 5 seconds: myLV.sendAndLoad("http://1.1.1.1/noFile.php",myLV,"POST"); // function to handle the load event: function load(p_evtObj:Object):Void { if (p_evtObj.success) { trace("Loaded successfully"); } else { trace("An error occurred while loading"); } }
// import the class: import com.gskinner.net.LoadVars2; myLV:LoadVars2 = new LoadVars2(); // subscribe to its data event: myLV.addEventListener("data",this); // add some data to send: myLV.username = "frank"; myLV.password = "cheesepenguin"; // set the timeout period to 10 seconds (default is 7s): myLV.timeout = 10000; // this should timeout after 10 seconds: myLV.sendAndLoad("http://1.1.1.1/noFile.php",myLV,"POST"); // function to handle the data event: function data(p_evtObj:Object):Void { if (p_evtObj.src != undefined) { trace("Loaded successfully with source: "+p_evtObj.src); } else { trace("An error occurred while loading"); } }
Follow @gskinner on Twitter for more news and views on interactive media.
|
|
|
9 Comments
a little pompous? ultimate loadvars solution?
Posted by: Nick Vent on Mar 16, 2004 3:26pm
(grin) - was just following the naming scheme I set with "Ultimate XML solution"
Intentional pomposity, intended humorously. :)
Cheers.
Posted by: Grant Skinner on Mar 16, 2004 3:33pm URL: http://gskinner.com/
AS 2.0: Extending Intrinsic Classes
I've been thinking a lot lately about Grant Skinner's rewrites of the XML and LoadVars classes, mainly to allow for true event broadcasting instead of simply using callbacks. Without talking specifics re the actual implementation, I just want to ...
Posted by: blog-j on Jun 16, 2004 3:41pm URL: http://blog.jasonnussbaum.com/archives/2004/0…
Very useful - thanks
Posted by: Jay Silva on Aug 2, 2004 8:46am
I'm trying to get LoadVars(originally) and now LoadVars2 on a subClass of a form without success. Any hints...
Posted by: Art on Feb 8, 2005 4:14pm
I've been having problems with the onTimeOut(). (onData != undefined) is always returning true, so I can't dispatch a 'load' event with success:false to my listener. Any suggestions?
Posted by: brew on Jul 8, 2005 6:09am URL: http://brookelgie.com
Greetings! We are conducting bet on sports online to all who are interested in playing games. Visit our site for more information and this online game is free for all! So what are you waiting for? Play now and enjoy our site! Happy gaming!
Posted by: Constance R. Vang on Jan 29, 2010 1:14pm
Seems to be a comprehensive tutorial.
Thanks...
Posted by: machine a sous on Feb 4, 2010 12:03pm URL: http://www.jouercasino.eu/machine-a-sous/
A bit hard for me but nice tutorial thank you :)
Posted by: julia on Sep 1, 2010 7:36am URL: http://www.top-poker.fr