Table of Contents
LZX uses JavaScript (ECMAScript, as defined by ECMA-262, edition 3), as a foundation for its scripting syntax. For more information please visit: http://www.ecma-international.org/.
Script can go in four places in an LZX application:
Inside an event attribute such as onclick
.
<canvas height="30"> <button onclick="animate('x', 10, 1000, true)">Click</example> </canvas>
In an attribute with type expression
.
Inside a constraint expression.
In a separate file that is included via the src
attribute of the <script>
tag.
<canvas> <include href="script.js"/> <!-- — --> </canvas>
The syntax and behaviour of LZX script is intended to be as specified by the ECMA-262 standard. However, there are some differences to be aware of, especially in the SWF runtime.
There are no exceptions, and no exception handling in the SWF runtime. try
/catch
/finally
is not supported.
Errors such as 1/0
,
, u
()
, k
()
, and u
.p
(where o
.u
is an undeclared variable, u
is defined but isn't a function, and k
is an object with property o
) are silently ignored in the SWF runtime. (If debugging is enabled, all but the first of these will generate a warning message
in the debugger window when evaluated.)
p
The best practice for detecting program errors in LZX code is to develop with debugging enabled (Chapter 50, Debugging) and to write unit tests (Chapter 51, Unit Testing).
The best practice for non-local transfer of control is to return a distinguished value or set a state variable.
Some ECMAScript objects and properties are not supported. See Table B.1, “Supported ECMAScript Properties” for a list of supported objects.
ECMA-262 is NOT the same as client-side JavaScript as implemented by web browsers. This means that the objects that
are browser specific (e.g. window
, document
, etc.) are not available to the LZX developer.
Forward references to functions are not supported.
LZX does not support the ECMAScript objects, attributes and methods presented in this font in the following table in the SWF runtime.
Table B.1. Supported ECMAScript Properties
ECMA Object | Properties | Methods | |||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
Error |
|
|
|||||||||||||||||||||||||||||||||||||
EvalError |
|
|
|||||||||||||||||||||||||||||||||||||
Function |
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
RangeError |
|
|
|||||||||||||||||||||||||||||||||||||
ReferenceError |
|
|
|||||||||||||||||||||||||||||||||||||
RegExp |
|
|
|||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||
SyntaxError |
|
|
|||||||||||||||||||||||||||||||||||||
TypeError |
|
|
|||||||||||||||||||||||||||||||||||||
URIError |
|
|
|||||||||||||||||||||||||||||||||||||
[a] [b] The [c] [d] [e] Using |
Reserved words may not be used as identifiers:
Table B.2. ECMAScript Keywords
Keywords | Reserved for future use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
A property of an object may have any name, even that of a reserved
word. object.property
and
object['property']
both refer to the
property
property of the object named
object
. When using dot syntax
(object.property
) property names must be a valid
identifiers, so object.default
, for example, is a syntax
error. In this case object['default']
can be used
instead.
LZX script implements a subset of class declarations, as specified by the ECMAScript 4 committee wiki. This extension is used in the LZX runtime implementation, but is not yet supported in user code.
Copyright © 2002-2007 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.