Mscape Help


How do I Control the Mediascape from the Flash Movie?

HELP You should read the document How to Control Flash from the Mediascape before following this section

It is possible to send notifications and data back to the Mediascape from within a Flash movie. For example, you may want to notify the mediascape when a particular Flash button on screen has been pressed, and then perform an action such as playing a sound in response.

This example will show how to achieve this effect.

on (press)
{
    fscommand("press");
}

This code uses the fscommand method to send a message to the mediascape containing the word "press". The mediascape will receive a OnFSCommand event on the Flash movie object carrying with it the data "press". The mediascape author can then choose to respond to this event by looking at the data and playing a sound in response.

Next we need to create the mediascape.

The script window (bottom-right panel) will list the event OnFSCommand on your Flash movie object. This event will be triggered every time there is a fscommand() method in the flash movie.

if (Command == "press")
{
    myAudio.Play();
}

(where myAudio is the name of the audio you just imported)

You can insert as many calls to fscommand() in your Flash actionscript as you want, for example you can have many buttons that send different commands. All of these commands will end up in the same place in the mediascape - the OnFSCommand event. In order to differentiate between the different commands in the mediascape you should add if blocks to your mediascape OnFSCommand code for each possible command. For example:

if (Command == "Press")
{
    myAudio.Play();
}
if (Command == "Pause")
{
    myAudio.Pause();
}
if (Command == "Exit")
{
    goodbyeImage.Show();
}
Topic attachments
I Attachment Action Size Date Who Comment
flafla PressExample.fla manage 32.5 K 25 Jul 2007 - 09:42 BenClayton? Flash FLA File used to demonstrate controlling a mediascape
wavmp3 beat.mp3 manage 94.9 K 25 Jul 2007 - 09:48 BenClayton? Example drumbeat audio
asas mediascape.as manage 1.8 K 25 Jul 2007 - 09:43 BenClayton? Mediascape Actionscript Flash Library

Ready to
get started?

Download Mscape Suite Version 2.1 | 10.5 MB

Download Mscape Beta

Experimental Beta Version 2.5 | 10.5 MB

Ask the Mscape Community

Forums