INTRODUCTION:
This tutorial shows you how to link 2 scripts together so that one
script calls a function (action) in another script. Both these scripts
are available in the Extras folder
supplied with Atmosphere 1.0. You can download
a ready made sample of
the simple world we'll be creating here or you can see it in action here.
STEP 1: Open your world
Load your world into the Adobe Atmosphere program.
STEP 2: Import onClick.js and playSound.js scripts
Make sure you are in Screen Editor
mode (e.g. by double clicking on the background away from any objects),
then click on File at the top left of the
screen, move across Import and click
on Script:

Now browse for the script onClick.js
which is in C: Program
Files/Adobe/Atmosphere/Extras/Scripts/Set_2_Intermediate and
click on it to load it into your Scene
Hierarchy.
Now do the same for the playSound.js
script which is in C: Program
Files/Adobe/Atmosphere/Extras/Scripts/Set_1_Basic
Both these script should now be in your Scene
Hierarchy.
STEP 3: Select a sound for playSound.js to play
Click on the script playSound.js
to highlight it, and in the Scripting Inspector
click on the variable URL to load it
into the Properties box:
Now RIGHT click in the Value
box and browse for a sound you'd like to play (there are lots of samples
in C: Program
Files/Adobe/Atmosphere/Extras/Audio):

Now click on runOnStartup in the Scripting
Inspector, and when this appears in the Properties
Name box type false into
the Value box (this just stops the
sound from playing at load time):

|
|
STEP
4: Set
box as the target for onClick.js
Click on <Solid Object> in the
Scene Hierarchy and in the Solid
Object Editor create a new Primitive
box (make it a large one so you can see it!):
Now click on the onClick.js script in the Scene Hierarchy to highlight
it, and and in the Scripting Inspector
click on the variable target to load
it into the Properties box:
 Now
click on Mr. Whippy and drag him
to <Box> in the Solid
Object Hierarchy:

<Box>.this will now appear in
the Value section of
Properties to show that the box is now the target
of this script i.e.clicking on the box will call this script.
STEP 5: Link onClick.js to
playSound.js
Now:
- click on the down arrow alongside playSound
in the Scene Hierarchy (to drop down its list of parameters)
- click on onClick
script in the Scene Hierachy
to show its parameters in the Scripting
Inspector
- click on the parameter onClick
in the Properties window of the Scripting
Inspector to show it in the Name
section
- click on Mr. Whippy and drag him
to play <action> in the Scene
Hierarchy
You can now see the words playSound.play
in the Value window. This basically
means that when the script onClick.js
is called (by clicking on the box) the play function (i.e.
<action>) of playSound.js will
be called. This simply plays the sound whose URL we loaded earlier.
STEP 6:Save and Publish your world
Once you've finished adjusting all the settings it's time to Save
and Publish your world:

STEP 7: Try it out!
Now load the published world and
test it out - just click on the box and it should play the sound for
you..
I'D LIKE HELP WITH......?
We hope you find this
introductory tutorial useful in getting you started with linking scripts
in Atmosphere 1.0. If you need help with this please visit our on line Conference
Room for tech help ( list of available times is available in the Events
Calendar) or post in our forums. If
there is another tutorial you'd particularly like to see and you think
would be of use to others please post in our forums
and we'll see what we can do! Cheers! The
HS Team |