我正在为我的在线脚本课程开发视频播放器,我的视频播放、播放和静音按钮都在正确的悬停状态和所有内容下工作。它们已正确定位并准备就绪。现在我必须创建我的时间滑块和我的音量滑块,这就是困难所在。我创建了一个名为 VolumeBar 的 ActionScript 3 文件,但我不知道它为什么不起作用。在我看来,它应该可以工作,但我认为我遗漏了一些东西。
我的符号是 BTN_Slider、BTN_VolumeBar 和 BTN_VolumeBarSlider。这些教程都没有帮助,因为它们都在我没有做的框架内使用“动作”功能
主要的
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.SoundTransform;
public class Main extends Sprite
{
static public var splash:SplashScreen;
private var theXMLFile:String = "VideoList.xml";
private var theVideoList:VideoList;
private var videoChoice:int = 0;
private var sndTransform:SoundTransform;
private var lastVolume:int = 1;
private var btn_Mute:BTN_Mute;
private var btn_Play:BTN_Play;
private var btn_Volume:VolumeBar;
static public var screenState:int = 0;
static public var nextState:int = 1;
public function Main()
{
theVideoList = new VideoList(theXMLFile);
btn_Mute = new BTN_Mute(581.3, 457.5);
btn_Play = new BTN_Play(42, 457.5);
btn_Volume = new VolumeBar(624.3, 457.5);
btn_Mute.addEventListener(MouseEvent.CLICK, clickedMute);
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):void
{
switch(screenState)
{
case 0 :
break;
case 1 :
videoChoice = 0;
nextState = 2;
displayScreen();
trace("TEST");
addChild(btn_Volume);
addChild(btn_Mute);
addChild(btn_Play);
break;
case 2 :
videoChoice = 1;
nextState = 3;
changeScreen();
break;
}
screenState = 0;
}
public function displayScreen():void
{
splash = new SplashScreen(theVideoList.videoXML.theVideo[videoChoice].fileLoc.text());
addChild(splash);
}
public function changeScreen():void
{
var toShow:String = theVideoList.videoXML.theVideo[videoChoice].fileLoc.text();
splash.connectVideo(toShow);
}
private function muteVolume(vol:Number):void
{
sndTransform = new SoundTransform(vol);
splash.vidStream.soundTransform = sndTransform;
}
private function clickedMute(mb:MouseEvent):void
{
if(btn_Mute.isMuted == true)
{
muteVolume(lastVolume = 1);
btn_Mute.isMuted = false;
}
else if(btn_Mute.isMuted == false)
{
muteVolume(lastVolume = 0);
btn_Mute.isMuted = true;
}
}
static public function togglePlay():void
{
splash.vidStream.togglePause();
}
}
音量条
import flash.display.*;
import flash.events.*;
import flash.geom.Rectangle;
public class VolumeBar extends MovieClip
{
var sliderControl = new BTN_Slider();
var sliderVolume = new BTN_VolumeBar();
var knobWidth:int = sliderControl.width;
var trackWidth:int = sliderVolume.width;
var trackX:int = sliderVolume.x;
var boundWidth = trackWidth - knobWidth;
var boundsRect:Rectangle = new Rectangle(trackX, 0, boundWidth, 0);
public function VolumeBar(theX:int, theY:int)
{
this.x = theX;
this.y = theY;
sliderControl.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
sliderControl.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
sliderControl.addEventListener(MouseEvent.MOUSE_OUT, stopDragging);
}
private function startDragging(mb:MouseEvent):void
{
sliderControl.startDrag(false, boundsRect);
}
private function stopDragging(mb:MouseEvent):void
{
sliderControl.stopDrag();
}
}
我现在想知道的是如何将它放在屏幕上并且基本上可以移动。一旦我做到了,我知道我可以自己搞定剩下的。感谢堆栈溢出者!