Table of Contents
LZX uses JavaScript (ECMAScript, i.e. ECMA-262), 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.
Identifiers are not case sensitive. For example, Boolean and boolean refer to the same value.
The best practice is to use identifiers with the proper case, as this discrepancy from ECMA-262 will be removed in a future release.
There are no exceptions, and no exception handling. try/catch/finally is not supported.
Errors such as 1/0, u(), k(), u.p, and o.u (where u is an undeclared variable, k is defined but isn't a function, and o is an object with property p) are silently ignored. (If debugging is enabled, all but the first of these will generate a warning message in the debugger window when evaluated.)
The best practice for detecting program errors in LZX code is to develop with debugging enabled (Chapter 45, Debugging) and to write unit tests (Chapter 46, Unit Testing).
The best practice for non-local transfer of control is to return a distinguished value or set a state variable.
When a String appears in a boolean context, only Strings that can be parsed as a non-zero number evaluate to true. The best practice is to use string.length to test for non-empty.
undefined converts to "" in a string context and to 0 in a numeric context. The best practice is to test for undefined explicitly using typeof(expression) == "undefined".
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.
Only Latin-1 and Shift-JIS characters are supported.
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.
Table B.1. Supported ECMAScript Properties
| ECMA Object | Properties | Methods | |||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Arguments |
|
||||||||||||||||||||||||||||||||||||||
|
Array |
|
|
|||||||||||||||||||||||||||||||||||||
|
Boolean |
|
|
|||||||||||||||||||||||||||||||||||||
|
Date |
|
|
|||||||||||||||||||||||||||||||||||||
|
Error |
|
|
|||||||||||||||||||||||||||||||||||||
|
EvalError |
|
|
|||||||||||||||||||||||||||||||||||||
|
Function |
|
|
|||||||||||||||||||||||||||||||||||||
|
Global |
|
|
|||||||||||||||||||||||||||||||||||||
|
Math |
|
|
|||||||||||||||||||||||||||||||||||||
|
Number |
|
|
|||||||||||||||||||||||||||||||||||||
|
Object |
|
|
|||||||||||||||||||||||||||||||||||||
|
RangeError |
|
|
|||||||||||||||||||||||||||||||||||||
|
ReferenceError |
|
|
|||||||||||||||||||||||||||||||||||||
|
RegExp |
|
|
|||||||||||||||||||||||||||||||||||||
|
String |
|
|
|||||||||||||||||||||||||||||||||||||
|
SyntaxError |
|
|
|||||||||||||||||||||||||||||||||||||
|
TypeError |
|
|
|||||||||||||||||||||||||||||||||||||
|
URIError |
|
|
|||||||||||||||||||||||||||||||||||||
|
[a] new Boolean() may not be used to coerce a String to a Boolean. [b] new Boolean() may not be used to clone a wrapper. [c] new Date(string) and Date.parse() are not supported. Passing a string to new Date(datestring) is not supported. The best practice is to construct dates from date components, for example: in place of new Date("7/20/1969") use new Date(1969, 7, 20). [d] The eval() function cannot be used to execute arbitrary code. It may only be used only to get the value of an identifier named by a String. [e] Math.LOG2E is incorrect on the Flash 5 player [f] Math.max() and Math.min() only support two arguments. [g] Using Object() to create a wrapper is not supported. [h] Object.toString always returns "[object Object]". [i] Using new String(value) to clone a wrapper is not supported. |
|||||||||||||||||||||||||||||||||||||||
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.
Copyright © 2002-2005 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.