on exitframe
(begins a frame behavior script Ð gear icon in cast)
on startmovie (begins a
global movie script Ð orange arrow icon in cast)
Examples:
sprite(2).loc=point(0,0)
Ð(sprite in channel 2 located at top left of stage)
sprite(2).rect=rect(0,0,160,120)
Ð (0,0) is top left coordinate and (160,120) is lower right coordinate of the
sprites bounding box
sprite(2).color=rgb(255,0,0)
Ð turns any BITMAP sprite a pure red
TYPES OF CAST MEMBERS: bitmaps, vector shapes, text fields, quicktimes
go next --go to the next marker AND go previous --go to the previous marker
go to the frame Ðloop playback
head in same frame
put ÒAndrew is aÓ &&
field ÒanimalÓ into field Òanswer
A ÒplaceholderÓ that holds a
numeric or string value. Example:
x=4
If you want a variable to be
in memory for the duration of the movie it has to be a global variable. Example:
global TrackObj
An excellent way to make
sprites in channels 10 through 20 all move off-screen!
repeat with x=10 to 20
sprite(x).loc=point(-500,-500)
end repeat
***ALWAYS PLACE COPY OF TTC
XTRA IN DIRECTOR XTRAS FOLDER BEFORE RUNNING MOVIE AND HAVE CAMERA CONNECTED
GrabToCast(TrackObj,[rect(0,0,320,240),17])
--This function grabs a
frame of live video with the bounding box (0,0,320,240) to the internal cast
member 17 (useful to store a copy of your reference frame)
CUSTOM VARIABLES IN TTC
EXAMPLE: tolerance = 40
--Tolerance is a number
between 1 and 100 defining how different a pixel needs to be from the same
pixel in the reference frame in order to be included in the result. The higher the number the less pixels
will be selected. You will need to
calibrate tolerance to your installation space.
GrabOneFrame(TrackObj)
--This function grabs a
reference frame (not to the cast just to system memory) for the duration of the
movie
TrackResults=TrackChangeBlobs(TrackObj,[[tolerance,Rect(0,0,320,240)]])
--TrackChangeBlobs is a
function that looks for changes in current video compared to the reference
frame. The function returns a
series of rect values.
1) Create a single frame movie with the same sprite (a
black or gray square) in channels 1 through 15 scattered all over the
stage. Write a repeat loop in the
on exitframe handler to move all the sprites to the location (0,0) on stage
when the movie is played.
2) Change your script in #1 to have the spites move to
random locations on stage.
3) Add a line to change the colors of the sprites (in
channels 1 through 15) randomly.
4) Delete the repeat loop and all the sprites except for
the one in channel 5. Run movie
and add this line of code: sprite(5).trails=1
5) Create a field to show the color value for sprite 5.
FINISHED?
Hook up a camera and examine
a test movie using TTC.
Open movie
trackchange_reference.dir (Available in the instructorÕs folder on ATS file
server.