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> <script src="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 SWF8 runtime.
There are no exceptions, and no exception handling in the SWF8 runtime: the SWF8 runtime does not signal any runtime errors.
 Errors such as 1/0, u()k()u.po.uukop
The best practice for detecting program errors in LZX code is to develop with debugging enabled (Chapter 51, Debugging) and to write unit tests (Chapter 52, Unit Testing).
The best practice for non-local transfer of control is to return a distinguished value or set a state variable.
In JavaScript, you can access the properties of an object in two ways:
foo.length foo['length']
In Javascript, these two expressions have identical meaning. The second form is normally used if you are trying to access a property whose name is stored in a variable. For instance, to enumerate the properties of an object you can say:
for (var key in myobject) ... myobject[key] ...
But in LZX script, there is one other subtle difference. When you use . to
                                  access a property, if the property does not exist, you will get a warning. If you
                                  use [ to access that non-existent property, you don't. In either case, the value
                                  of the expression will be undefined. 
               
 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. 
               
LZX does not support the ECMAScript objects, attributes and methods presented in this font in the following table in the SWF8 runtime.
Table B.1. Supported ECMAScript Properties
| ECMA Object | Properties | Methods | 
|---|---|---|
| 
                                                                         | 
                                                                         
                                                                         | |
| 
                                                                         | 
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                        new Date( 
                                                                        parse( 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         toDateString() toGMTSting() toLocaleDateString() 
                                                                         toLocaleTimeString() 
                                                                         toTimeString() toUTCString() 
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         | 
| EvalError | EvalError.prototype constructor message name | EvalError(message) new EvalError(message) toString() | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         toString() [b] | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         | decodeURI() 
                                                                         encodeURI(uri) 
                                                                         
                                                                         
                                                                        eval( 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         max(...) [d] min(...) [d] 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         toFixed() toExponential() toPrecision() 
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         toString() [e] 
                                                                         | 
| RangeError | RangeError.prototype constructor message name | RangeError(message) new RangeError(message) toString() | 
| ReferenceError | ReferenceError.prototype constructor message name | ReferenceError(message) new ReferenceError(message) toString() | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         | 
| 
                                                                         | 
                                                                         
                                                                         
                                                                         | 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         localeCompare(that) 
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         toLocaleLowerCase() toLocaleUpperCase() 
                                                                         
                                                                         
                                                                         
                                                                         | 
| SyntaxError | SyntaxError.prototype constructor message name | SyntaxError(message) new SyntaxError(message) toString() | 
| TypeError | TypeError.prototype constructor message name | TypeError(message) new TypeError(message) toString() | 
| URIError | URIError.prototype constructor message name | URIError(message) new URIError(message) toString() | 
| [a]  [b]  [c] The  [d]  [e]  [f] 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 proposed by the ES-Harmony committee wiki. This extension is used in the LZX runtime implementation, but is not yet supported in user code.
Copyright © 2002-2010 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.