Accessibility

Director Article

 

Using JavaScript Syntax in Director MX 2004 for 3D Visualization


Andrew Phelps

Andrew M Phelps

andysgi.rit.edu
www.it.rit.edu

Table of Contents

Created:
9 February 2004
User Level:
Advanced

The shift to JavaScript syntax is a major advancement to Macromedia Director, and is important for a number of reasons. The feature provides a more common language and syntax between Macromedia Flash MX and Macromedia Director. In Director, the language implementation is on top of the SpiderMonkey engine [1], which is a pre-packaged ECMAScript interpreter written in C and complies largely to the ECMA specification [2], except in areas where custom functions or keywords expose Director-specific functionality.

For the first time, a standards-compliant and robust language choice is available in Director. It allows developers with expertise in ActionScript, JavaScript syntax, or traditional programming languages such as Java/C/C++ to more effectively use that knowledge within the Director MX 2004 environment. At the Rochester Institute of Technology, several of the faculty and students have experience with various scripting languages—the opportunity for programmers to work in a common language in Director MX, Macromedia Flash, and the web has long been a desire.

If you're familiar with any of the aforementioned languages, then the fundamental issue is learning how the JavaScript syntax implementation in Director MX wraps around traditional Lingo features. To that end, I explain a project that uses JavaScript syntax exclusively, and that uses features that developers use most commonly in Director (the Shockwave3D and Havok modules). The project also demonstrates several of the new features in object-oriented design. Please note that the code in this article is not a complete application—in fact, it is a prototype for a more complex tool that I plan to write in native code. I often use Director as a prototyping tool; in this article, I use Director to test whether the visualizations of the file system (See Figure 1) are effective enough to require a more robust, lower-level program.

Sample visualizations from the demo code-base,
    depicting “interactive mode” [top] and “render mode” scenes of a typical Windows XP installation
    at a search depth of three levels.

Figure 1: Sample visualizations from the demo code-base, depicting “interactive mode” [top] and “render mode” scenes of a typical Windows XP installation at a search depth of three levels.

Requirements

To complete this tutorial you will need to install the following software and files:

Director MX 2004

Sample files for this article:

Definition and History of ECMAScript

ECMAScript and the Browser

Originally, the ECMAScript standard described a language created by Brendan Eich at Netscape [2] and appeared in the Netscape 2.0 Internet browser in early 1994. Since that time, several companies have integrated a similar language into their products under competing names, two of the most well known are JavaScript (Netscape) and JScript (Internet Explorer / Microsoft). Several versions of the language existed, each with minor differences, prompting the need for a common standard across implementations—the first release of the ECMA standard was in 1998

Since that time, updated specifications have reflected changes and advancements in the technology. The latest standard is ECMA-262 Edition 3 (ISO/IEC 16262) and errata [3]. When Netscape began the open-source Mozilla project, they released the SpiderMonkey engine, which is a C implementation of the langauge that developers can plug into other products for ECMAScript support. Director MX 2004 builds its JavaScript syntax on top of this framework.

About the author

Andrew Phelps is an assistant professor at the Rochester Institute of Technology, in Rochester, NY. He is the founding faculty member of the Game Programming Concentration within the Department of Information Technology and his work in games programming education has been featured in The New York Times, CNN.com, USA Today, National Public Radio, and several other articles and periodicals. He also regularly publishes in the Director Online User's Group (DOUG) on topics related to graphics, rendering, and 3D worlds, including the popular D3DISO series. He maintains a website featuring his work as an educator, artist, programmer, and game addict, and currently teaches courses in multimedia programming, game engine development, 2D and 3D graphics, web design, and information technology theory. He can be reached at amp@it.rit.edu.