index_subhead

starting and stopping your animation

If your animation contains video, sound or complex animations then you must implement two functions in the main timeline of the Flash file in order to allow the Nxtbook to control when it plays.

You should never allow sound or video to begin playing immediately within your animation. All sound, video and animations must only play when the startMedia() function is called and stop completely when stopMedia() is called.

startMedia()

The startMedia() function will be called when the Nxtbook is ready to display your animation to the reader. Your animation may be loaded before it is actually shown and should wait to play any sounds or videos until this function is called. For instance, if you had an FLV player on the stage named flv, you should include a function on the main timeline of your animation that looks something like this:

function startMedia():void {
flv.play();
}

stopMedia()

This stopMedia() function will be called when the Nxtbook is going to hide and unload the animation, giving you the opportunity to stop any videos or sounds that are currently playing when the reader changes the page. Using the same FLV player example as above, you would want to include the following code on the main timeline of your animation:

function stopMedia():void {
flv.stop();
}

Controlling the Nxtbook from within an animation

Animations have some ability to communicate with the Nxtbook they are loaded into. In order to call a function in the Nxtbook insert the following function in the main timeline of your fla:

function nxtbookCommand(...args):void {
try {
parent["nxtbookCommand"].apply(parent, args);
} catch(e:Error){}
}

Once this function exists in your timeline you can call it passing various command names and arguments to the Nxtbook.

Click here for a list of available commands and their arguments.