Week 10 - Xtras

Xtras Overview, Loading New Xtras, Using New Xtras, Cleaning Up After Xtras, Serial Xtra, asFFT Xtra, Other Xtra

Xtras Overview

There are certain things/functions that are not built into Director.
Luckily, Director is extensible - and so people can write Xtras to
add functionality to the program. Gives you the power of low-level
programming in high-level Director environment.

Certain Xtras come with the Director application. And in fact,
we have already used Xtras without even realizing it.
For example: Netlingo, Quicktime Support
They are located in the Xtras folder in the Director folder.

You can tell which Xtras are loaded into Director using the
the command:
showxlib

There are lots of other extras that the community of Director developers
have created (usually in C++). You can browse through them at this Macromedia site.

Most of them are not free but many have a demo component that will allow
you to use it only in authoring mode (not as a projector or shockwave).

N.B. Xtras are not cross-platform. So be specific about which ones you
download.

Loading New Xtras

First, you find an Xtra you want and then download it.

Two ways to load:
You could put it in the Xtras folder.
But this is Not Recommended in case
you want to make a projector, etc.

Put the Xtra in the same folder as your director movie.
Use the openxlib command in the startmovie handler:

on startmovie
    openxlib "xtraNameAsDocumentedByShowXlib"
end


Use showxlib to make sure it worked.

Using New Xtras

To figure out what Xtras can do for you,
check the documentation!!!

Check on the various sites for documentation.
Also, Xtras are self-documenting.
Use the command:
put mmessagelist( xtra "xtraNameAsDocumentedByShowXlib" )

This shows you all the different commands that you can use.

To start using your Xtra
You have to create a new instance of it and store it in a global variable,
like so:

global mySpecialXtra

on startmovie
    mySpecialXtra = new(xtra "xtraNameAsSpewedBackByShowXlib", paramtersIfNeeded)
end


To use functions, call your Xtra and then append the function/command you want to use, e.g.
mySpecialXtra.functionName(parameter,parameter..)

This is object-oriented syntax...

Cleaning Up after Xtras

This is something we haven't had to deal with much - since Director
takes good care of memory issues for the most part.

But Xtras tend to eat up a lot of memory.
So it's important to clear the Xtra instance out of memory when you're done with it. Do this by making the global variable = to 0.

global mySpecialXtra
on stopmovie
   mySpecialXtra = 0
end


If your movie stops because of some other error, this script won't be run
and you may run into memory issues. One thing to do is clear out the variable in startmovie handler instead (before your Xtra initialization.)

Serial Xtra

Get it from physicalbits.com. You'll need to request a license number and then put it into the script.

gSerialPort = new( xtra theXtraName,"esther.drill@verizon.net","XFD0-X64V-JR68-QPDF",90)

My advice: Use this with a computer that has a serial port.
Otherwise, see Dan's guidance for figuring out how to deal with a USB port instead - you'll need to get a serial-to-USB adapter...

So the idea here is that you have a stamp on the one hand that you have
programmed in physical computing to record a variety of inputs (photocell,
slide, switch) and then send them out through the serial cable.
Your stamp is also waiting to receive some input (related to the mouseloc)
back from the serial cable (that will affect the servo motor).
Here's Dan's stamp program...

On the other hand, you are using this Xtra to get the information that is coming
in through the serial cable into Director. And you are also sending information
back out.

asFFT Xtra

Get it from http://www.as-ci.net/asFFTXtra/.
Will work in authoring mode even though it puts up an alert.
Analyzes sound input into frequency bands.
Make sure your input device is set properly.

Other Xtras

SoundLevel Xtra (Doesn't work on Mac OSX) from physicalbits.com
Danny Rozin's trackthemcolors from smoothware.com or itp mac server