Mscape Help


How To: Use a timer

Imagine making a mediascape in which you want something to happen after a period of time. For example, you might want to end a game after the user has been playing for ten minutes, or show an image five seconds after the user has entered a region. It is easy to do this in mscape by using the Timer object. This brief tutorial will show you how.

Let's begin by starting the mscape maker and creating a new mediascape.

The next step is to right click on the Tools section and select Add Timer

addTimer.gif

Now right click on the new Timer object and select Add Alarm

addAlarm.gif

This adds a new alarm object to the mediascape called Alarm01. An alarm object has the following important characteristics:

Let's give the timer something to do when it fires. First, we need some media. Follow the guide to importing media to add an audio object and name it myAudio. Now click on the Alarm01 object and look at the lower part of the maker where you will see that the script window currently points at the the alarm's OnRing event:

onRingEvent.gif

Drag the myAudio object into this window and drop it. Then type "." and select Play from the drop down list. Alternatively, click inside the empty script wiindow and type myAudio.Play();. Either way, you should now see this:

onRingDefined.gif

Next we want to set the period for the alarm. To the left of the script window, you should see Alarm01's properties. Click on the cell next to Period and type 10:

alarmPeriod.gif

Now, all that is left is to set the alarm. Click on the Mediascape object. You should be able to see the OnLoaded event in the script window. Drag and drop the Alarm01 object into this window, type "." and select Start from the drop down list. Alternatively type Alarm01.Start(); directly into the script window.

alarmStart.gif

That's it! Now we have a simple mediascape consisting of a timer with a single alarm that will fire 10 seconds after the mediascape is loaded and play a short audio. If you have been following along in the mscape maker, try your mediascape now in the tester. Or click on the link below to download the mediascape we have just been making from the main web site. Note that this version also has an image that is shown on load to confirm that the mediascape is working.

Try right-clicking on the Alarm01 object and selecting Help to find out what else you can do with a timer alarm. Experiment with starting an alarm in the onEnter event in a region, or define multiple alarms... See what it can do, and have fun!

Ready to
get started?

Download Mscape Suite Version 2.1 | 10.5 MB

Ask the Mscape Community

Forums