Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Extending Flash MX 2004, Part 2: Using Classes and Scripts in JSFL

If you're experienced with ActionScript—or even JavaScript—JSFL won't be a stretch. There's just a few idiosyncrasies you need to know about. Find out how to write and execute your own JSFL scripts.


advertisement
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



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date