Using Javascript

Although Javascript in Director is far from perfect (slower than lingo, some nasty bugs such as "setPref crashing Director":http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=f35fc669&pss=rss_director_f35fc669, and general lack of useful documentation) - there are some reasons to use it - at least to provide some functionality not otherwise available in Lingo. For example, Javascript syntax gives you access to regular expressions for searching and replacing text. Although quite limited compared to the "PregEx Xtra":http://openxtras.org - it will work in Shockwave (unlike PregEx). "Here is an example script":http://www.lingoworkshop.com/code/classes/scripts/JS_RegEx.ls with some wrapper functions for searching, replacing and splitting strings with regular expressions. Note, however, that the regular expression object doesn't seem quite complete in Director (for example, the results of a re.exec(str) seem to be missing a few properties). There are also several algorithms implemented in Javascript that can be used in Director 'as is'. For example, here are some javascript implementations of "Blowfish":http://en.wikipedia.org/wiki/Blowfish_(cipher) and "Block TEA":http://www.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html (Tiny Encryption Algorithm) * "Blowfish":http://www.farfarfar.com/scripts/encrypt/ * "Block TEA":http://www.movable-type.co.uk/scripts/TEAblock.html You can simply cut and paste these scripts into Director, and they work as is (although they may be limited by Director's internal handling of text?).
First published 18/02/2006