【AN】制作二维机械专业的动画课件,播放、停止、显示和拖拽

下面代码实现了播放、停止、显示结构图,需要配合舞台的美术资源、元件动画来实现

stop();
Bt_play.addEventListener(MouseEvent.CLICK, playmc);
function playmc(event:MouseEvent):void
{
	MC_LINE01.play();
	MC_Jiantou.play();
	MC_xiexian.play();
	MC_LINE02.play();
	MC_xuanzhuan.play();
	
}
Bt_zanting.addEventListener(MouseEvent.CLICK, Zanting);
function Zanting(event:MouseEvent):void
{
	MC_LINE01.stop();
	MC_Jiantou.stop();
	MC_xiexian.stop();
	MC_LINE02.stop();
	MC_xuanzhuan.stop();
}
Bt_stop.addEventListener(MouseEvent.CLICK, tingzhi);
function tingzhi(event:MouseEvent):void
{
	MC_LINE01.gotoAndPlay(1);
	MC_Jiantou.gotoAndPlay(1);
	MC_xiexian.gotoAndPlay(1);
	MC_LINE02.gotoAndPlay(1);
	MC_xuanzhuan.gotoAndPlay(1);
}

Jiegou.addEventListener(MouseEvent.CLICK, Jiegouxianshi);
function Jiegouxianshi(event:MouseEvent):void
{
	STR.play()
}

 下面代码和上面一样,不过既实现了上面的也实现了拖动改变倾斜角(画面左下角的效果)

 

stop();
import fl.motion.MotionEvent;//侦听
import flash.events.MouseEvent;//按钮控制 类包 
import flash.display.MovieClip; //需要引入命名空间/也是一个类,自定义类定义完毕以后如果要引用也需要这样引用,这是影片剪辑控制必备的类包
import flash.geom.Rectangle;

var IsJiegoudisplay: Boolean = false;//按钮状态变量
var IsYaodiandisplay: Boolean = false;//按钮状态变量

//------------------------------------------------


Jiegou.addEventListener(MouseEvent.CLICK, _Jiegou);//侦听按钮
Bt_play.addEventListener(MouseEvent.CLICK, GoPlay);//侦听按钮
Bt_zanting.addEventListener(MouseEvent.CLICK, _zanting);//侦听按钮
Bt_stop.addEventListener(MouseEvent.CLICK, _stop);//侦听按钮


function _Jiegou(e: MouseEvent)//控制结构指示图是否显示的按钮侦听函数
{
	if(IsJiegoudisplay)
	{
			structtxt.gotoAndPlay(1);
		IsJiegoudisplay=false;
		}
		else{
			structtxt.gotoAndPlay(2);
					IsJiegoudisplay=true;
			}	
	}
	
function GoPlay(e: MouseEvent)//
{
	MC_xuanzhuan.play();
	this.play();
	MC_Jiantou.play();
	MC_LINE01.play();
	MC_LINE02.play();
	MC_xiexian.play();
	}
	function _zanting(e: MouseEvent)
{
	MC_xuanzhuan.stop();
	this.stop();
	MC_Jiantou.stop();
	MC_LINE01.stop();
	MC_LINE02.stop();
		MC_xiexian.stop();
	
	}
	function _stop(e: MouseEvent)
{
	MC_xuanzhuan.gotoAndStop(1);
	this.gotoAndStop(1);	
	Mc_Quxian.gotoAndStop(1);
	MC_Jiantou.gotoAndStop(1);
	MC_LINE01.gotoAndStop(1);
	MC_LINE02.gotoAndStop(1);
			MC_xiexian.gotoAndStop(1);

	}
	
var left:Number=214 ;//bar_mc.x-line_mc.width/2;//绘制一个矩形范围,坐标起点 最左边的坐标557-894
var leng:Number =306;// bar_mc.x+line_mc.width/2;从坐标起点算起,到最右边的矩形长度  520-214=286 还要加上小球半径20像素
var bottom:Number=0;//line_mc.y; //滑块活动范围 底部
var top:Number=803;//line_mc.y;滑块所处的纵坐标

	
bar_mc.addEventListener(MouseEvent.MOUSE_DOWN,Drag);
bar_mc.addEventListener(MouseEvent.MOUSE_UP,StopDrag);
bar_mc.addEventListener(MouseEvent.MOUSE_MOVE,Movemouse)
//----------------------------------------------------------
function Drag(event:MouseEvent):void 
	{
 var rect:Rectangle=new Rectangle(left,top,leng,bottom);//绘制一个拖拽活动矩形,起点left,长度是 right,矩形Y坐标终点是 top 矩形Y坐标起点是 bottom,top-bottom等于 活动矩形的宽度
 bar_mc.startDrag(false,rect);			

}
function StopDrag(event:MouseEvent):void 
{
 bar_mc.stopDrag();
}

function Movemouse(event:MouseEvent)//侦听鼠标移动后的执行函数
{
var numFrame:int=30*(bar_mc.x-214)/leng;	//214是矩形长度,bar_mc.x 是滑块当前坐标	
if(numFrame==0){numFrame=1}
Mc_Quxian.gotoAndStop(numFrame);
	}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Unity3d青子

难题的解决使成本节约,求打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值