ECMAScript is a family of languages developed for use on the web. The most common of these languages are JavaScript, used by Gecko and Webkit applications; JScript, used in Internet Explorer; and ActionScript, used in Flash. These languages bear a striking resemblance to GraalScript, and in an effort to make code that is more easily ported to and from Flash applications and the web, some features of these languages were added to GraalScript. Below is a summary of some of these features.

Trace
The trace function is used in ActionScript, typically for debugging purposes. In GraalScript, it is an alias for the echo command.
See also: trace

Var
Use of the keyword var in ECMAScript creates a variable whose scope is the body of the function in which it is declared. The var keyword is ignored by the GraalScript compiler, since temp variables already have this property.

Static
Another keyword that is reserved in GraalScript but is unused is static. In ECMAScript, this would bind a function to a class rather than an instance. This behavior can be duplicated in GraalScript, in a way, by using the public qualifier and joining the function to the object (usually a TStaticVar).

Anonymous functions
On the other hand, a function can be bound to an instance rather than a class simply by using an anonymous function.
obj.some_function = function (params) { statements; };
This syntax can be used in GraalScript, although it is somewhat broken. However, anonymous functions in GraalScript are treated as regular functions (with their own separate scope), so while this would display '3' in ECMAScript:
function A() {
  var hats = 3;
  this.getHats = function() { return hats; };
  return this;
}
function B() {
  var a = A();
  trace(a.getHats);
}
B();
GraalScript would produce '0'.

Additionally, the properties of the MovieClip object reflect the names of the equivalent properties in ActionScript (e.g., _x and _y, as opposed to x and y)

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki