7.
Add the following ActionScript to Frame 1 of the main Timeline:
import flash.external.ExternalInterface;
/* Register playVideo() and pauseResume() so that it is possible
to call them from JavaScript in the container HTML page. */
ExternalInterface.addCallback("playVideo", null, playVideo);
ExternalInterface.addCallback("pauseResume", null, pauseResume);
/* The video requires a NetConnection and NetStream object. */
var server_nc:NetConnection = new NetConnection();
server_nc.connect(null);
var video_ns:NetStream = new NetStream(server_nc);
/* Attach the NetStream object to the Video object on Stage so
that the NetStream data is displayed in the Video object. */
selected_video.attachVideo(video_ns);
/* The onStatus() method is called automatically when the status of
the NetStream object is updated (the video starts playing, for example).
When that occurs, send the value of the code property to the HTML page by
calling the JavaScript updateStatus() function via ExternalInterface. */
video_ns.onStatus = function(obj:Object):Void {
ExternalInterface.call("updateStatus", "
};
function playVideo(url:String):Void {
video_ns.play(url);
}
function pauseResume():Void {
video_ns.pause();
}
The first part of this ActionScript code defines two ExternalInterface callback functions,
and
playVideo()
next procedure. The second part of the code creates a new NetConnection and NetStream
object, which you use with the video instance to dynamically play back FLV files.
The code in the next procedure defines an
NetStream object. Whenever the NetStream object changes its status, Flash uses the
ExternalInterface.call()
updateStatus()
the playback of the video instance on the Stage. Both of these functions are called from
JavaScript written in the following procedure.
672
Working with External Data
. These functions are called from the JavaScript in the
pauseResume()
method to trigger the custom JavaScript function,
. The final two functions,
" + obj.code);
event handler for the
onStatus
and
playVideo()
pauseResume()
video_ns
, control
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?