Articles Archive
Articles Search
Director Wiki
 

Save as Java

February 9, 1999
by Steve Kury

Java is a hot new internet-oriented programming language whose presence is growing rapidly. The demand for developers skilled in its use is high and growing. However, a considerable portion of Java applets could be developed simply in Director with the "Save as Java" feature. I sometimes wonder why more developers do not learn how to use Director to create Java applets for the Internet, thus increasing their value to their companies and clients. I attribute it to two reasons; 1) they don't know why they should use Director for it, and 2) They don't know how to use Director to do it well.

Why

The "why" question is relatively easy to address. Four basic reasons are:

Suitability to Director

Certain genres of Java applets lend them to development in Director. These are simple score based animations and banners, UI elements, and quiz games. Genres that would not be effective as Java applets are Lingo based animations and reflex-twitch games.

The reason that Lingo based animations and reflex-twitch games are not effective as applets is that Java applets produced by Director run much more slowly than as Director movies, with less temporal precision. Thus anything that requires precise timing and cat-like reflexive responsiveness, such a shooting gallery game, will not function as desired in the form of Java applets.

Easy development

Director has a built-in animation engine which makes it easy to develop animations. Why go through the effort of coding them in Java if you can simply lay them out in the score and save them as applets? This process is much faster and eliminates the need for hard core Java expertise and development environment such as J++.

No need to know Java

While "Save as Java" does relieve developers of the need for honed Java skills for simple applets, the better a developer's Java skills, the better off they are because they would have a greater understanding of what they are creating in Director. Don't be fooled, though. It would be rather impractical to attempt to do hard core Java development in Director. Save as Java is not meant for that. For example, if you want to produce a UI front end to a more complex Java based system, the UI could be developed in Director, saved as Java source code, and handed off to a Java engineer to complete the guts of it and integrate it into the system. Trying to do the entire system, including the back end, in Director with Lingo would not work.

Some intranets ban Shockwave

If the goal is simple animations and banners, Java applets allow the developer to address the broadest audience possible because the need for plugins is alleviated. This would be applicable on some intranets where the Shockwave/Flash plugins are not available.

How

The "how" question is a little bit more complicated to address. First and foremost the Director source movie must be developed, from the start, with the goal of a Java applet in mind. This entails knowing the limitations of Save as Java.

Many of the common features of Director are not supported by Save as Java. Therefore, trying to convert any already existing movie into an applet would most likely be a rough process, creating many compilation errors, and frustrating the developer.

It is important to know which features are and aren't supported by Director before creating the source movie for the applet, and incorporate into that movie only those that are. These include knowing which ink effects, fonts, and Lingo commands, to name a few, are and aren't supported.

For example;

When preparing Lingo for conversion to Java, it is important to understand the issues of case translation and variable type derivation. The case translation is important because Java is case sensitive and Lingo isn't. For example:


myVar = 5
MYvAR = 8

In Lingo this would assign two different values to the same variable. Lingo doesn't distinguish between the different capitalization styles between them. But in Java, the same code would be handled as instantiating two different variables, each with a different value. When Director converts Lingo to Java, it will take the first spelling of a variable that it encounters and convert all instances of that variable that it encounters after that to it.

Variable type derivation becomes an issue because Lingo's variables are polymorphic, allowing them to contain different information types (integer, float, string, list). Java requires variables to be declared as a specific type before being used and doesn't allow for them to be changed during the operation of the program. For example, the following is acceptable in Lingo:


x = 5
x = 9.2
x = "harry"

In this example the variable type associated with x is changed from integer to floating point to text (string). In Java x would have to be declared as one of the three types, and afterwards it could only hold that type of information. For example:


int x
string y
x = 5
y = "harry"

The following is not acceptable in Java:


int x
string y
x = "foo"
y = 7.8764

Be assured that knowledge of the limitations of "Save as Java" will definitely reduce the amount of development time that would be spent debugging a movie that does not successfully compile into an applet.

With all of this in mind, become versed in the potential and limitations of Save as Java and start making Java applets with Director preferably profitable ones. Be sure to visit the Macromedia Save as Java applet gallery, and see some in action.

More information
The "Authoring for Save as Java" documentation can be downloaded as a PDF file from the Director What's New section of the Macromedia website.

Steven Kury is an interactive media developer living in the SF Bay area. He has worked on several integrated CD-ROM/internet/backend systems and has good breadth of experience in interactive media, including a stint as a QA engineer on the Director engineering team at Macromedia. He can be contacted at skury@primenet.com.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.