With the sharp increase in the use of media to provide information to web users, many developers want their users to be able to stream media and then control it. You might use media components in the following kinds of situations:
Suppose you must develop a website that allows users to preview DVDs and CDs that you sell in a rich media environment. The following example shows the steps involves. (It assumes your website is ready for inserting streaming components.)
Next, you'll set the cue point time such that it is within a few seconds of the end of the clip.
This places a symbol called Window in your library.
mySale_mc movie clip in the library, select Linkage, and select Export for ActionScript.
This places the movie clip in your runtime library.
// Import the classes necessary to create the pop-up window dynamically
import mx.containers.Window;
import mx.managers.PopUpManager;
// Create a listener object to open sale pop-up
var saleListener = new Object();
saleListener.cuePoint = function(evt){
var saleWin = PopUpManager.createPopUp(_root, Window, false, {closeButton:
true, title: "Movie Sale ", contentPath: "mySale_mc"});
// Enlarge the window so that the content fits
saleWin.setSize(80, 80);
var delSaleWin = new Object();
delSaleWin.click = function(evt){
saleWin.deletePopUp();
}
saleWin.addEventListener("click", delSaleWin);
}
myMedia.addEventListener("cuePoint", saleListener);
If you want a lot of control over the look and feel of your media display, you may want to use the MediaDisplay and MediaController components together. The following example creates a Flash application that displays your CD and DVD preview media.
horizontal property to false.
backgroundStyle to None.
This specifies that the MediaController instance should not draw a background but should instead fill the media between the controls.
Next, you'll use a behavior to associate the MediaController and MediaDisplay instances so that the MediaController instance accurately reflects the playhead movement and other settings in the MediaDisplay instance, and so that the MediaDisplay instance responds to user clicks.
myMediaDisplay under _root and click OK.
For more information on using behaviors with media components, see Controlling media components by using behaviors.
The Component inspector makes it easy to set media component parameters, properties, and so on. To use this panel, click the desired component on the Stage and, with the Property inspector open, click Launch Component Inspector. The Component inspector can be used for the following purposes:
It is important to understand a few concepts when working with the Component inspector:
Note: You can set the FPS value only by using the Component inspector. Setting an fps value by using ActionScript has no effect and is ignored.
Behaviors are prewritten ActionScript scripts that you add to an instance, such as a MediaDisplay component, to control that object. Behaviors let you add the power, control, and flexibility of ActionScript coding to your document without having to create the ActionScript code yourself.
To control a media component with a behavior, you use the Behaviors panel to apply the behavior to a given media component instance. You specify the event that will trigger the behavior (such as reaching a specified cue point), select a target object (the media components that will be affected by the behavior), and, if necessary, select settings for the behavior (such as the movie clip within the media to navigate to).
The following behaviors are packaged with Flash MX Professional 2004 and are used to control embedded media components.
| Behavior | Purpose | Parameters |
|---|---|---|
|
Associate Controller |
Associates a MediaController component with a MediaDisplay component |
Instance name of target MediaController components |
|
Associate Display |
Associates a MediaDisplay component with a MediaController component |
Instance name of target MediaController components |
|
Labeled Frame CuePoint Navigation |
Places an action on a MediaDisplay or MediaPlayback instance that tells an indicated movie clip to navigate to a frame with the same name as a given cue point |
Name of frame and name of cue point (the names should be equal) |
|
Slide CuePoint Navigation |
Makes a slide-based Flash document navigate to a slide with the same name as a given cue point |
Name of slide and name of cue point (the names should be equal) |
myMediaDisplay under _root and click OK.
Note: If you have associated the MediaDisplay component with the MediaController component, you do not need to associate the MediaController component with the MediaDisplay component.
myMediaController under _root and click OK.
The cue point indicates the amount of time that should elapse before you navigate to the selected frame. For example, if you want to jump to myLabeledFrame 5 seconds into the media, enter 5 in the SS text box and enter myLabeledFrame in the Name text box.
_root clip and click OK.
The cue point indicates the amount of time that should elapse before you navigate to the selected slide. For example, if you want to jump to mySlide 5 seconds into the media, enter 5 in the SS text box and enter mySlide in the Name text box.
Presentation under the _root clip and click OK.