03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

The following example creates a LoadVars object called my_lv:<br />

var my_lv:LoadVars = new LoadVars();<br />

onData (LoadVars.onData h<strong>and</strong>ler)<br />

onData = function(src:String) {}<br />

Invoked when data has completely downloaded from the server or when an error occurs while<br />

data is downloading from a server. This h<strong>and</strong>ler is invoked before the data is parsed <strong>and</strong> can<br />

be used to call a custom parsing routine instead of the one built in to Flash Player. The value<br />

of the src parameter passed to the function assigned to LoadVars.onData can be either<br />

undefined or a string that contains the URL-encoded name-value pairs downloaded from the<br />

server. If the src parameter is undefined, an error occurred while downloading the data from<br />

the server.<br />

The default implementation of LoadVars.onData invokes LoadVars.onLoad. You can<br />

override this default implementation by assigning a custom function to LoadVars.onData,<br />

but LoadVars.onLoad is not called unless you call it in your implementation of<br />

LoadVars.onData.<br />

Parameters<br />

src:String - A string or undefined; the raw (unparsed) data from a LoadVars.load() or<br />

LoadVars.sendAndLoad() method call.<br />

Example<br />

The following example loads a text file <strong>and</strong> displays content in a TextArea instance called<br />

content_ta when the operation completes. If an error occurs, then information displays in<br />

the Output panel.<br />

var my_lv:LoadVars = new LoadVars();<br />

my_lv.onData = function(src:String) {<br />

if (src == undefined) {<br />

trace("Error loading content.");<br />

return;<br />

}<br />

content_ta.text = src;<br />

};<br />

my_lv.load("content.txt", my_lv, "GET");<br />

See also<br />

onLoad (LoadVars.onLoad h<strong>and</strong>ler), onLoad (LoadVars.onLoad h<strong>and</strong>ler), load<br />

(LoadVars.load method), sendAndLoad (LoadVars.sendAndLoad method)<br />

LoadVars 371

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!