我有一个用 actionscript 3 编写的 360 度视图。如何使用播放/暂停按钮控制滑块?我能够让代码工作,但我只是想不出一种方法来控制使用播放/暂停按钮的滑块。我将其用于产品查看器。
private function createSlider():void
{
//Create a librarie object in the stage.
_roteableObject = new LibrarieObject();
_roteableObject.x = stage.stageWidth / 2 - _roteableObject.width / 2;
_roteableObject.y = 0;
_roteableObject.gotoAndStop(1);
addChild(_roteableObject);
//Create the slider
_slider = new Slider();
_slider.minimum = 1;
_slider.maximum = _roteableObject.totalFrames;
addChild(_slider);
_slider.width = stage.stageWidth - 250;
_slider.addEventListener(SliderEvent.THUMB_DRAG, sliderChangeHandler);
_slider.move(stage.stageWidth / 2 - _slider.width / 2 + 90, _roteableObject.y + 25 + _roteableObject.height - 10);
_slider.addEventListener(MouseEvent.MOUSE_DOWN, stop360);
//play / stop button
_play_btn = new play_btn();
_stop_btn = new stop_btn();
addChild(_play_btn);
addChild(_stop_btn);
_stop_btn.visible = false;
_play_btn.addEventListener(MouseEvent.MOUSE_UP, play360);
_stop_btn.addEventListener(MouseEvent.MOUSE_UP, stop360);
}
private function sliderChangeHandler(e:Event):void
{
_roteableObject.gotoAndStop(e.target.value);
}
private function play360(e:Event):void
{
_roteableObject.play();
_play_btn.visible = false;
_stop_btn.visible = true;
}
private function stop360(e:Event):void
{
_roteableObject.stop();
_play_btn.visible = true;
_stop_btn.visible = false;
}
}
}