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.

The object parameter becomes the context in which the properties, variables, <strong>and</strong> functions<br />

in the statement(s) parameter are read. For example, if object is my_array, <strong>and</strong> two of the<br />

properties specified are length <strong>and</strong> concat, those properties are automatically read as<br />

my_array.length <strong>and</strong> my_array.concat. In another example, if object is<br />

state.california, any actions or statements inside the with statement are called from<br />

inside the california instance.<br />

To find the value of an identifier in the statement(s) parameter, ActionScript starts at the<br />

beginning of the scope chain specified by the object <strong>and</strong> searches for the identifier at each<br />

level of the scope chain, in a specific order.<br />

The scope chain used by the with statement to resolve identifiers starts with the first item in<br />

the following list <strong>and</strong> continues to the last item:<br />

■ The object specified in the object parameter in the innermost with statement.<br />

■ The object specified in the object parameter in the outermost with statement.<br />

■ The Activation object. (A temporary object that is automatically created when a function<br />

is called that holds the local variables called in the function.)<br />

■ The movie clip that contains the currently executing script.<br />

■ The Global object (built-in objects such as Math <strong>and</strong> String).<br />

To set a variable inside a with statement, you must have declared the variable outside the with<br />

statement, or you must enter the full path to the Timeline on which you want the variable to<br />

live. If you set a variable in a with statement without declaring it, the with statement will<br />

look for the value according to the scope chain. If the variable doesn't already exist, the new<br />

value will be set on the Timeline from which the with statement was called.<br />

Instead of using with(), you can use direct paths. If you find that paths are long <strong>and</strong><br />

cumbersome to type, you can create a local variable <strong>and</strong> store the path in the variable, which<br />

you can then reuse in your code, as shown in the following ActionScript:<br />

var shortcut = this._parent._parent.name_txt; shortcut.text = "Hank";<br />

shortcut.autoSize = true;<br />

Parameters<br />

object:Object - An instance of an ActionScript object or movie clip.<br />

Example<br />

The following example sets the _x <strong>and</strong> _y properties of the someOther_mc instance, <strong>and</strong> then<br />

instructs someOther_mc to go to Frame 3 <strong>and</strong> stop.<br />

with (someOther_mc) {<br />

_x = 50;<br />

_y = 100;<br />

208 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!