Zat Home
Documentation | Examples

Spin™ Examples


This page describes the example projects that come with Spin. These example projects fall into two categories:
  1. Applications, found in the examples subdirectory of Spin. These applications have their own user interface, and can be saved as either stand-alone applications or as applets.
  2. Servlets, found in the exampleservlets subdirectory of Spin. These examples are designed to run on a Web server, and they generate HTML output that can be displayed in a standard Web browser.

If you have a Spin project that you would like to have included here, please send it to


Each example consists of one file in the examples subdirectory of the Spin installation directory, and optionally several files in the asset subdirectory. All of the examples are capsules that can be opened directly from within Spin.

BlueBoxClick (1K)

Displays a blue box that when clicked turns a different shade of blue. Demonstrates use of a simple behavior. Note that when used in the toybox, closing and reopening the toybox will start again. The toybox only stores edited changes, not changes based on behavior execution.

Beans: zat.display.Rect.

Assets: none.

Bounce (3K)

Displays two objects, a box and a ball, contained within an opaque scene. Each have the same complex behavior -- bounce -- that drops the object and makes it bounce when clicked with the mouse.

Beans: zat.display.Rect, zat.display.ImageURL.

Assets: asset/ball.gif.

Clock (9K)

A combination analog, digital, and cuckoo clock, all in one! For demonstration purposes, you can click on the clock to make it cuckoo. To make it act like a normal cuckoo clock, change the cuckoo behavior (under the chime actor) to activate on Time.hour.timeChanged rather than background.Mouse.mouseClicked. Note that an analog clock is an example of something that would be difficult to build in an authoring tool like Director.

Beans: zat.misc.Time, zat.misc.AudioURL, zat.display.Rect, zat.display.Drawable, zat.display.Text

Assets: asset/snd/

Cloning (2K)

Demonstrates the ability to clone capsules. This example contains a Capsule that has as its contents a ball that bounces when the capsule is cloned. Clicking the button clones the capsule. Note that the toybox view does not support capsule cloning. You should run this project to see it work.

Beans: zat.display.Oval.

Assets: none.

CubeWReverse (39K)

Displays an rotating cube with a button that reverses its direction. Demonstrates IfTest behavior, and the ability to activate several behaviors in top-down order via a single event.

Beans: zat.display.AnimatedGIFURL.

Assets: asset/anim/zatcube.gif.

Drag (2K)

Displays a single rectangle which can be dragged around with the mouse. The drag behavior is a complex behavior created within the tool. Also available as a prebuilt user behavior.

Beans: zat.display.Rect.

Assets: none.

Happy (112K)

An animating behavior example. Displays two animated characters over a background. The happy guy can be dragged around, and jumps when clicked. Try attaching jump behaviors to other objects (including the background).

Beans: zat.display.AnimatedGIFURL, zat.display.ImageURL.

Assets: asset/background.gif, asset/anim/happyrun.gif, asset/anim/bunny.gif.

The delightful animated characters in this example are copyright Marina Zurkow of O-Matic — many thanks to her for letting us use them.

HappyKick (12K)

Shows the use of timeline behaviors to control motion over time. The first timeline sends our hero Happy running at a ball to kick it. The second timeline sends the ball flying when the first timeline stops.

The background image in this example contains two shaded gradients. On Windows 95 and 98, the IBM JRE that comes with Spin consumes a lot of system resources when rendering the gradients, and can cause odd color problems or repaint problems if you try and work with several capsules or other windows applications at once.

Beans: zat.display.AnimatedGIFURL, zat.display.ImageURL, zat.display.Gradient.

Assets: asset/ball.gif, asset/anim/happyrun.gif.

Juggler (78K)

The juggler example from the tutorial. Shows the use of an expression in an action behavior.

Beans: zat.demo.Juggler, java.awt.Button, java.awt.Scrollbar.

Scribble (2K)

A simple drawing application. Allows you to draw multiple lines to make an image. Also allows the color of the image to be changed.

Beans: zat.display.Drawable, zat.display.Rect.

Assets: none.

SlideShow (13K)

Displays a simple slideshow with two slides, and a next and previous button to navigate between them. Illustrates the use of sharing visuals between scenes, and the use of animated gifs create buttons.

Beans: zat.display.Rect, zat.display.AnimatedGIFURL, zat.display.ImageURL, zat.display.Text, zat.display.Oval

Assets: asset/stripe.gif, zat.gif, zatinc.gif, asset/anim/next.gif, previous.gif.

SlideShowTransition (13K)

Same as above, but with a simple rolling transition between scenes.

Beans: zat.display.Rect, zat.display.AnimatedGIFURL, zat.display.ImageURL, zat.display.Text, zat.display.Oval

Assets: asset/stripe.gif, zat.gif, zatinc.gif, asset/anim/next.gif, previous.gif.

StockGraph (2K)

Displays current stock graph images fetched from the yahoo site. Enter a ticker symbol, and hit Display, or simply choose a symbol from the list.

Beans: zat.display.ImageURL.

Assets: none.

StockGraphLocal (21K)

Displays stock graph images fetched from a limited set on disk. Essentially this is the same as StockGraph above, except it does not require an Internet connection. Symbols are limited to those for which there are assets (see list below), and of course the stock data is not current.

Beans: zat.display.ImageURL.

Assets: chart/a/aapl.gif, adbe.gif, adsk.gif,
chart/c/cisc.gif, cpq.gif,
chart/m/macr.gif, msft.gif
chart/t/tek.gif, txn.gif


To run these example projects from within Spin, you must have the Spin debug Web server enabled. From the Spin Edit menu, select "Preferences..." and set the WebServerEnabled preference to true (in the DebugServer tab). The ServerPort preference sets on which port the debug server will serve Web pages. If you already have a Web server on your machine which is serving pages on port 80 (the default for Web servers), then you must change this value to something else (typically port 90 on Windows or Macintosh, or port 8080 on Unix).

Once the Spin debug Web server is enabled, you can open any standard Web browser (such as Netscape Navigator or Microsoft Internet Explorer) and point it at the URL http://localhost. If you have changed the ServerPort preference, then you will have to specify the port number after the host name, separated by a colon. For example, if you have changed the port number to 8080, then set your browser to listen to http://localhost:8080. The Spin debug Web server will display all open servlets; you can execute the servlet by clicking on the servlet name.

In addition, many of these projects use the PointBase database. You can either start the database manually (by executing the PointBase Server application), or set the PointBaseServerLoadsAtStart preference to true (in the General tab of the Spin Preferences dialog).

The easiest way to run these examples is to open the exampleservlets/exampleProject.zap project. From there, you can open individual example capsules or projects.

printprops (3K)

Simple servlet that displays the value of all the Java System properties. Useful to show all the system values that are available to a servlet, and also as an example of a simple servlet.

dropListExample (8K)

drop-down list

Example that demonstrates how to display an HTML select element, initialized with with a series of options retrieved from a database. Populating a select element from a database is a very common servlet task.

calculator (9K)

Six function calculator that works like an adding machine with a tape. Makes extensive use of multiple stimuli on action events, and exception handling.

mortgage (10K)

Servlet-based mortgage payment calculator.

tableExample (8K)

Example that dumps out a database table and displays it as an HTML table.

bugdb (50K)

bug database

Reasonably large database-enabled example servlet, this is the bug tracking system used at Zat. You can search for bugs, add new bug reports, and edit existing bug reports. To run it, open the servlet bugdb.zac.

Uses: public_html/examples/bugbd

netcard (245K)

An application for sending and receiving greeting cards over the Web. The project netcard.zap contains three servlets: netcard.zac, pickup.zac, and request.zac. Includes an example of how to send email from a servlet.

To run this example, you must open the request.zac servlet and double-click on the "mailmessage" bean to edit its properties. Fill in the "Mailhost" property with the name of the SMTP server you use for sending email. Then close the request.zac servlet, and finally open the netcard.zac servlet and execute it.

The netcard.zac servlet displays 6 greetings cards that can be sent via email. The request.zac servlet processes the greeting card chosen from netcard.zac and sends the card once the sender and receiver have been entered. The recipient of the greeting card receives an email message with a URL for the pickup servlet, which displays the appropriate card (selected by the parameters given as part of the URL).

Uses: public_html/examples/netcard

poll (95K)

list of polls

A set of servlets for taking user polls. The servlet polladmin.zac is used to create new polls and edit existing polls. It creates HTML for your poll, which you can cut and paste into another Web page. This HTML calls the pollvote.zac servlet, which records the vote and displays the current voting results.

Uses: public_html/examples/poll

jpeg (21K)

A set of three servlets that demonstrate the use of the JpegSaver bean. This bean lets you create an image dynamically on the server, and download it as a JPEG image to a browser. Also shows how to call one servlet from another.

The ballPage.zac servlet calls the ballImage.zac servlet to draw increasingly zoomed in views of a simple image. The clockimage.zac servlet draws an analog clock showing the current time. The samplePage.zac servlet draws an image and encodes it using various levels of quality, showing the tradeoff between image quality and image size.

Uses: asset/ball.gif

15 March 2000 — wm