Ghosts in the Machine: Introduction to PC scripting

Back to Multimedia Daily Schedule

Open a new movie. Save it as "parent1.dir."

(We will not be playing the movie, so stage size or color does not matter.)

Create a new script, choose Window>Script: Name this script "CoolCucumber."

---

on HowIsUni

put "No worries, but I need sleep!"

end

on WhatDoYouStudy

put "Underwater Basket Weaving"

end

on WhereAreYou

put "Los Angeles"

end

---

3. Create another script and name it "StressedStudent": Type:

on HowIsUni

put "I have a headache!"

end

on WhatDoYouStudy

put "Interactive Multimedia Art"

end

on WhereAreYou

put "Chicago, IL"

end

4. In the properties dialog boxes of both scripts, use the pull-down menu to change their script type to "Parent".

5. Open the message window and type:

set Bruce = new (script "CoolCucumber")

set Dean = new (script "StressedStudent")

We have just had the 'birth' of 2 child objects, one from each parent script. the primary syntax for creating child objects is: set Object = new (script "Parent Script")

6. In the message window, enter: HowIsUni Bruce

The object performs as instructed -- "No worries, but I need sleep!"

7. In the message window, enter: HowIsUni Dean

The object performs as instructed -- "I have a headache!"

You can continue asking Bruce and Dean questions, using WhatDoYouStudy and WhereAreYou, and see how they respond. It is important to note that child objects, like variables, exist entirely in RAM. It's possible to add scriping to control a physical object, like a sprite on the stage, but the manifestation of the child object itself is has a ghost-like presence in your computer.