Skip to Content »

FlashApe » LoadVars for Javascript

 LoadVars for Javascript

  • April 22nd, 2005
  • 1:14 pm

I put together this LoadVars class for javascript for users who would rather deal with the flash LoadVars object than the XMLHttpRequest object (this LoadVars class is pretty much just a wrapper for that object). It’s quick and dirty but it works.
A few notes about the class:
¥ all requests use GET. the send and sendAndLoad methods will automatically convert the properties of the LV object to a query string and append it to the URL.
¥ You dont need to escape the return value coming back to the LV object. You can send a plain string if you like. However, you can set the LoadVars.parseVarString to true, and you can pass in a string like “myVar=This is the ver&myvar2=This is the secondvar.” You don’t need to encode the string, but if you do it will decode it.
¥ the return value is always accepted by the same LV object. In flash, you can specify a target object..that is not used here.
¥ only string or number datatypes may be used.
¥ getBytesLoaded/getBytesTotal aren’t implemented.
¥ there is a LoadVars.onLoadError method you can use to handle situations such as document not found.
You can test it out here.
You can grab the source files here.
Posted by flashape at 05:05 PM | Comments (1)

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>