2021-09-11 来源:网络
Flash AS3教程:如何实现控制影片播放速度
本例实现通过鼠标调整来达到控制影片播放速度的动画,你可以把鼠标移向右下角的红圈中的红点,然后左右拖动鼠标试试,就可以看到动画效果了,演示如下:
如何实现控制影片播放速度的动画制作步骤如下:
步骤一、新建一个“背景”图层,并于其中设计场景动画的基本内容;
步骤二、建立“摩天轮”图层,并于基中加入摩天轮影片剪辑“wheel_mc”;
步骤三、新建“控制钮”图层,先加入旋钮控制区的影片剪辑“jog_mc”,接着加入旋钮“drag_btn”按钮与用来显示速度的动态文本框“fsp_txt”;
步骤四、新增图层“文稿”,选第1帧,按F9打开动作面板,输入Action Script代码如下:
wheel_mc.stop();
var Rot=0;
var actMode;
var playStep=0;
var Pn=1;
drag_btn.addEventListener(MouseEvent.MOUSE_DOWN,chgYes);
function chgYes(me:MouseEvent){
actMode="yes";
}
drag_btn.addEventListener(MouseEvent.MOUSE_UP,chgNo);
function chgNo(me:MouseEvent){
actMode="no";
}
jog_mc.addEventListener(MouseEvent.MOUSE_MOVE,chkRot);
function chkRot(me:MouseEvent){
if(actMode=="yes"){
var mX=jog_mc.mouseX;
var mY=-(jog_mc.mouseY);
Rot=Math.atan2(mX,mY)/(Math.PI/180);
drag_btn.rotation=Rot;
}
}
stage.addEventListener(Event.ENTER_FRAME,cirPlay);
function cirPlay(me:Event){
Pn=1;
if (Rot<0 pn="-1;" playstep="Math.floor(Math.abs(Rot)/30);" if="" playstep="">5){
playStep=5;
}
fps_txt.text=String(playStep * 12 * Pn);
for (var i=1;i<=playStep;i++){
if(Pn>0){
wheel_mc.nextFrame();
if (wheel_mc.currentFrame==wheel_mc.totalFrames){
wheel_mc.gotoAndPlay(1);
}
}else{
wheel_mc.prevFrame();
if (wheel_mc.currentFrame==1){
wheel_mc.gotoAndPlay(wheel_mc.totalFrames);
}
}
}
}
这样,Flash AS3教程:如何实现控制影片动播放速度的动画制作就完成了,你可以下载源码学习学习!