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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

The following example saves text to a shared object named my_so (for the complete example,<br />

see SharedObject.getLocal()):<br />

var my_so:SharedObject = SharedObject.getLocal("savedText");<br />

// myText is an input text field <strong>and</strong> inputText is a dynamic text field.<br />

myText.text = my_so.data.myTextSaved;<br />

// Assign an empty string to myText_ti if the shared object is undefined<br />

// to prevent the text input box from displaying "undefined" when<br />

// this script is first run.<br />

if (myText.text == "undefined") {<br />

myText.text = "";<br />

}<br />

changedListener = new Object();<br />

changedListener.onChanged = function (changedField) {<br />

my_so.data.myTextSaved = changedField.text;<br />

inputText.text = "";<br />

inputText.text = my_so.data.myTextSaved;<br />

}<br />

myText.addListener(changedListener);<br />

flush (SharedObject.flush method)<br />

public flush(minDiskSpace:Number) : Object<br />

Writes shared object to a local, persistent file. To guarantee that the shared object will be<br />

written to the device, the application must force a write operation by calling the flush()<br />

method.<br />

Unlike in Flash Player, the write operation is asynchronous <strong>and</strong> the result is not immediately<br />

available.<br />

Parameters<br />

minDiskSpace:Number - An integer specifying the number of bytes that must be allotted for<br />

this object. The default value is 0.<br />

Returns<br />

Object - A Boolean value, true or false; or a string value of "pending". The flush()<br />

method returns pending for most requests, with the following exceptions:<br />

■ If there is no need to write data (that is, the data has already been written), flush()<br />

returns true.<br />

SharedObject 557

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

Saved successfully!

Ooh no, something went wrong!