Loading data for mobile devices in flash lite – Adobe Flash Professional CS3 User Manual

Page 506

Advertising
background image

FLASH CS3

User Guide

500

// First case: variable attached to a movie or

// movie clip timeline

//

// Create the Date object.

var mcDateObject = new Date();

// Returns the current date as a string.

trace(mcDateObject);

// Delete the object.

delete mcDateObject;

// Returns undefined.

trace(mcDateObject);

//

// Second case: global variable attached to a movie or

// movie clip timeline

//

// Create the Date object.

_global.gDateObject = new Date();

// Returns the current date as a string.

trace(_global.gDateObject);

// Delete the object.

delete _global.gDateObject;

// Returns undefined.

trace(_global.gDateObject);

As mentioned previously, you can’t use the

delete

statement to free memory that a local function variable uses.

Instead, set the variable reference to

null

, which has the same effect as using

delete

.

function func()

{

// Create the Date object.

var funcDateObject = new Date();

// Returns the current date as a string.

trace(funcDateObject);

// Delete has no effect.

delete funcDateObject;

// Still returns the current date.

trace(funcDateObject);

// Set the object reference to null.

funcDateObject = null;

// Returns null.

trace(funcDateObject);

}

// Call func() function.

func();

For more tips and techniques for creating content for mobile phones and devices, see

www.adobe.com/go/learn_cs_mobilewiki_en

.

Loading data for mobile devices in Flash Lite

When developing files for mobile devices, minimize the amount of data you attempt to load at one time. If you are
loading external data into a Flash Lite file (for example, using

XML.load

), the device’s operating system may generate

a “memory failure” error if insufficient memory is allocated for the incoming data. This situation can occur even if
the total amount of remaining memory is sufficient.

Advertising