To build the user interface you need to drag five Button instances
onto the display list and give them the following instance names:
playButton
,
pauseButton
,
stopButton
,
backButton
,
and
forwardButton
.
For each of these Button instances, you’ll need to assign a handler
for the
click
event, as seen in the following snippet:
playButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
pauseButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
stopButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
backButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
forwardButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
The
buttonClickHandler()
method uses a switch
statement to determine which button instance was clicked, as seen
in the following code:
private function buttonClickHandler(event:MouseEvent):void
{
switch (event.currentTarget)
{
case playButton:
ns.resume();
break;
case pauseButton:
ns.togglePause();
break;
case stopButton:
ns.pause();
ns.seek(0);
break;
case backButton:
playPreviousVideo();
break;
case forwardButton:
playNextVideo();
break;
}
}
Next, add a Slider instance to the display list and give it an
instance name of
volumeSlider
. The following code
sets the slider instance’s
liveDragging
property
to
true
and defines an event listener for the slider
instance’s
change
event:
volumeSlider.value = volumeTransform.volume;
volumeSlider.minimum = 0;
volumeSlider.maximum = 1;
volumeSlider.snapInterval = 0.1;
volumeSlider.tickInterval = volumeSlider.snapInterval;
volumeSlider.liveDragging = true;
volumeSlider.addEventListener(SliderEvent.CHANGE, volumeChangeHandler);
Add a ProgressBar instance to the display list and give it an
instance name of
positionBar
. Set its
mode
property
to manual, as seen in the following snippet:
positionBar.mode = ProgressBarMode.MANUAL;
Finally add a Label instance to the display list and give it
an instance name of
positionLabel
. This Label instance’s
value will be set by the timer instance