>>Scripts from the ASCII Kitty example:

This movie uses only one frame in the score and has a very vertical layout of sprites in the score--sprites do not need to be spread out horizontally over multiple frames of the score if you control what appears on the stage through lingo instead through the playback head location. Newer versions of Director use "autopuppeting" which allows you to do this. When you make one frame movies you need to use the lingo term "updateStage" often to refresh what you see on the stage.


The Movie Script that plays before your Director movie even starts:

**The movie script, which plays first when you start up a Director movie, is where you declare global variables, initialize variable values, intitialize what will appear on the first frame of the movie, and store handlers that you may want to call from elsewhere in the program. However, recently lingo programming is moving away from a centralized movie script which contains the bulk of your code to distributed reusable behaviors which are attached to specific sprites and contain their own adaptable properties instead of global variables--overall a more object oriented approach.

on startMovie

--sets intial text fields to empty

put "" into field 10
put "" into field 17



--This is all one behavior. This same behavior is attached to the fishybites, milk, yarn, and
--badkitty sprites, it adjusts its parameters to each one through the use of sprite specific



--properties function like variables, storage containers for paramaters that potentially change

property mySprite
property myIntialloc
property theMember



--this handler runs when the sprite is first activated

on beginSprite me

Initialize me

end beginSprite



on Initialize me

-- sent by beginSprite handler, initializes all the values held in the properties

--assigns the property named mySprite to whatever sprite this behavior happens to be attached to
mySprite = sprite(me.spriteNum)

--assigns the property named theMember to whatever member happens to be contained in the sprite
theMember = mySprite.member

--puts the inital location of the sprite into a property called myIntialloc so the sprite can be returned to that location later
myIntialloc = mySprite.loc

end Initialize


on mouseDown me

--a repeat loop that while the mouse is pressed down sets the food sprite
--to the mouse location(makes it draggable)

repeat while the mouseDown = true

mySprite.loc = the mouseloc

--an if statement that checks whether the food sprite is touching the
-- cat(an invisible button, sprite 10, is over the cat head area)

if sprite mySprite intersects sprite 10 then

--a "nested if statement" inside the above if statement that checks which
--cast member is in the sprite and assigns the appropriate word response

if mySprite.member = member("fishybites") then
else if mySprite.member = member("milk") then
put "worms" into field 10
else if mySprite.member = member("yarn") then
put "meow" into field 10
else if mySprite.member = member("badkitty") then
put "hiss" into field 10
end if

end if
end repeat

--puts the food sprite back where it started using the myInitialloc property when you let go of the mouse

on mouseUp

mySprite.loc = myIntialloc

--empties the text response field
put "" into field 10




This cast member script is attached to the "submit" button cast member:


on mouseUp

--this is a cast member script, not a behavior. It chooses a random answer from the cat when you "submit" your question

global gWhichanswer
set gWhichanswer = random(3)

if gWhichanswer = 1 then
put "purr" into field 10
else if gWhichanswer = 2 then
put "meow" into field 10
else if gWhichanswer = 3 then
put "hiss!!" into field 10

end if

--empties out the question text field

put "" into field 17