
Sample Applications 49
9 Create the event handler for the Play button. If the user selects Play, update the button label,
create an input stream, and play the selected recording.
// Do Play
function doPlay ()
{
if (Play_btn.getLabel() == "Play") {
Status_msg.text="Playing...";
Play_btn.setLabel("Stop");
// Get the selected recording
var playFileName = Play_list.getSelectedItem().label;
// Create input stream and play the recording
in_ns = new NetStream(_root.client_nc);
in_ns.play(playFileName);
in_ns.onStatus = function(info)
{
// Handle errors and stream stopping
if (info.level == "error" || info.code == "NetStream.Play.Stop") {
Status_msg.text="Stopped sending data...";
Play_btn.setLabel("Play");
}
}
Replay_video.attachAudio(in_ns);
10
If the user selects the Play button when the label is set to Stop, close the input stream and
update the button label.
} else if (Play_btn.getLabel() == "Stop") {
Status_msg.text="...";
//Close the stream
in_ns.onStatus = null;
in_ns.close();
Play_btn.setLabel("Play");
}
}
To test your sample application:
1 In the Flash MX authoring environment, after you have saved your work, publish it by
selecting File > Publish.
2 Open two instances of the SWF file in the application directory.
3 Add recordings to the playlist and play them back. Remember that titles containing more than
one word are not supported.
Kommentare zu diesen Handbüchern