
n this article I will discuss the similarities and differences between ActionScript and JSFL. We will also briefly show you how to write your own JSFL scripts and how to execute them.
As with ActionScript, JSFL has a set of predefined classes, containing methods and properties:
- Array
- Boolean
- Date
- Function
- Math
- Number
- Object
- RegExp
- String
ActionScript coders will notice one extra class, the RegExp class. No, that isn't a mistake; you can use regular expressions in JSFL!
In JSFL, as in ActionScript, every string is an instance of the String class, every array is an instance of the Array class, every number is an instance of the Number class, etc. Which means that strings, numbers, arrays, booleans, objects, etc., are treated in exactly the same way as they are in ActionScript
All Strings have the usual String methods: 'substr,' 'charAt,' 'indexOf,' etc. All Arrays have the usual Array methods: 'splice,' 'pop,' 'push,' and so on.
So for example, you can write:
myStr="A,B,C,D";
bits=myStr.split(","); //use a string method
Or:
myStr="abcd";
myStrLen=myStr.length; //get a string property
In either JSFL or ActionScript the above code snippets produce the same result. For a complete list of each class's available methods and properties refer to the
Netscape JavaScript API documentation.
Top-Level Properties and Methods
JSFL also contains some top-level functions. These are functions that are not related to any particular object or class and thus can be used anywhere in your scripts, as is.
- encodeURI
- decodeURI
- eval
- Infinity
- isNaN
- Number
- parseFloat
- parseInt
- alert