Archive for May, 2006

Filming a Movie

May 29, 2006

A simple script to show how animations are done:

tell application “Apex”
starting the movie
set destinationFile to “Macintosh HD:coercion movie”
start filming of window 1 of document 1 saving in destinationFile
saving movie frames
repeat 90 times
rotate window 1 of document 1 axially 0.1
rotate window 1 of document 1 vertically 1
save movie frame of window 1 of document 1
end repeat
stopping the movie
stop filming of window 1 of document 1
end tell

Basically, there are three phases of the script: starting the filming, saving frames, and stopping the filming.

In this script, the name of the movie is hard coded. That’s a problem if you’d like to run the script a number of times. If you’d like to generate a different name for the movie each time, try doing this:

set secs to (( current date ) – (date “Sunday, January 1, 2006 12:00:00 AM” ))as text
set destinationFile to “Macintosh HD:movie ” & secs

secs will be the number of seconds since the first of the year, so as long as you wait one second between script runs, you’ll have a different name for the movie file. Or perhaps you’d like to name the file with a traditional Mac OS put file dialog. In which case, do this:

set destinationFile to choose file name

You’ll have interesting results if you change the size of the window while the script is running. QuickTime movies have a fixed size, so the size that you start with is the size you’ll get no matter what.

Advertisements