ARS361
Interactive Digital Multimedia
Instructor: B. Lattanzi
rev.2.8.04

Use Director to store code objects and data in computer memory for retrieval any time during a series of otherwise-separate and autonomous movies, as shown in the following scripts.

Why is this an interesting idea?

Reasons to experiment with these "virus"-like entities include:

  1. These stored code objects and data can then be used to change and modify the images and events of the current Director movie playing, in a way that plays with the expectations of the viewer who is interacting with the movie.
  2. We can link together different movies by different people, and weave the movies together through shared data and functions that flow across the movies, even as these become modified dynamically within any given movie.

(Note that Director protects the computer system from these invisible entities by expunging them from computer ram once the entire Director project is closed.)

--------------------------------------------------------------------------------------------------------------------------

-- Global variables are similar to property variables. Just like a property variable, a global can hold any kind of data.

-- Globals are different though, because they have a life beyond the individual script, and even beyond an individual movie. Globals can contain information that affects the playback of any movie that is connected to the movie in which it first appears.

------"start.dir" file----------------------------
-- 1 script:
------------------------------------------------------
-- BEHAVIOR SCRIPT ATTACHED TO SPRITE
-------------------------------------------------------

global SpriteImageSpiritOntheLoose, ghostlyGreetings

on mouseDown me
   clearglobals
-- Use this statement to insure that no globals remain (in this case, from previous movies during authoring).
                                     -- To remove a specific global, you could just refer to it by name, e.g., myGlobal = VOID.

      SpriteImageSpiritOntheLoose = member("ghost").picture
   ghostlyGreetings = "greetings from the other side"
end

on mouseUp me
   play movie "redLights.dir"

       --When referring to the name of an external Director file (or any string - i.e., text in quotes), treat it as case-sensitive!
end

------"redLights.dir" file------------------------
--3 scripts:

------------------------------------------------------------
-- a MOVIE SCRIPT in the cast member library
------------------------------------------------------------

global SpriteImageSpiritOntheLoose, ghostlyGreetings

on startMovie
   member("red graphic").duplicate(member(5))
   member(5).name = "red graphic twin"
end

-------------------------------------------------------------------------
-- a BEHAVIOR SCRIPT attached to a sprite on the stage
---------------------------------------------------------------------------

global SpriteImageSpiritOntheLoose, ghostlyGreetings

property redSprite, anothermovie

on beginSprite me
   redSprite = sprite(me.spriteNum)
   anothermovie = "creepy.dir"
end

on mouseDown me
   if ghostlyGreetings <> VOID then
      member("hidden thoughts").text = ghostlyGreetings
-- This text was defined in another movie.
   end if
   if SpriteImageSpiritOntheLoose <> VOID then
      member("red graphic").picture = SpriteImageSpiritOntheLoose
-- This was defined in another movie too!
   end if
end

on mouseUp me
   play movie anothermovie
-- this sends playback to another movie identified by the variable "anothermovie"
end

-------------------------------------------------------------------------
-- a BEHAVIOR SCRIPT attached to another sprite on the stage
---------------------------------------------------------------------------

on mouseDown me
   sprite(me.spriteNum).member = "red graphic twin"
end

on mouseUp me
   play done -- this sends the playback automatically to the previous movie played
end

----------------------------------------------------