实现3d360度拖拽旋转加载的功能
以下是我整理的在Flash as中关于3d360度拖拽旋转 加载的方法
代码:
class DragCtrlPlay extends MovieClip {
//被拖拽MC的总帧数:
private var total_frames:Number;
//被拖拽MC的当前帧数:
private var current_frame:Number;
//鼠标点击图片时的x坐标:
var start_x:Number;
//拖拽控制灵敏度:
var drag_dx:Number;
//响应拖拽的开关:
var is_ctrl:Boolean;
//构造函数:
function DragCtrlPlay() {
init();
}
//各项初始化:
private function init() {
total_frames = this._totalframes;
current_frame = 1;
drag_dx = 5;
is_ctrl = false;
this.gotoAndStop(1);
this.onRollOver = mcOnRollOver;
this.onPress = mcOnPress;
this.onRelease = this.onReleaseOutside=mcOnRelease;
this.onMouseMove = mcOnMouseMove;
}
//鼠标onRollOver事件:
private function mcOnRollOver() {
//不显示鼠标手势:
//this.useHandCursor = false;
}
//鼠标onPress事件:
private function mcOnPress() {
//记录鼠标点击图片时的x坐标:
start_x = _xmouse;
//打开响应开关:
is_ctrl = true;
}
//鼠标onRelease事件:
private function mcOnRelease() {
//关闭响应开关:
is_ctrl = false;
//更新当前帧数:
current_frame = this._currentframe;
}
//鼠标onMouseMove事件:
private function mcOnMouseMove() {
if (is_ctrl) {
//实时获取鼠标当前x坐标:
var current_x:Number = _xmouse;
//播放的帧数差:
var frame_d:Number = Math.ceil((current_x-start_x)/drag_dx);
//影片播放到当前帧数差的位置:
mcGotoAndStop(frame_d);
//更新画面显示,使拖拽效果不受影片帧速影响:
updateAfterEvent();
}
}
//影片播放到当前帧数差的位置:
private function mcGotoAndStop(__d) {
//影片最终播放并停止到的帧数:
var frame_final:Number = current_frame+__d;
//超出帧数范围会循环播放:
while (frame_final>total_frames) {
frame_final -= total_frames;
}
while (frame_final<1) {
frame_final += total_frames;
}
//最后gotoAndStop到计算好的帧数:
this.gotoAndStop(frame_final);
//直观起见显示一下帧数:
showDebugInfo("当前帧数:"+frame_final);
}
//显示调试信息:
private function showDebugInfo(__info) {
_parent["debug_txt"].text = __info;
}
}
库里有个mc链接着这个类 如果想用这个mc去加载外部影片可以用嵌套的方法来控制这个mc了
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |