求大神给我解释下这一段Flash代码,希望可以尽量详细
MouseMove.aspackage{importflash.display.MovieClip;importflash.events.Event;importflas...
MouseMove.as
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
public class MouseMove extends MovieClip {
private var _mc:MovieClip;
private var Y:Number;
private var _distance:Number;
private var directions:Number=-1;
public function MouseMove(target:MovieClip,distance):void {
_mc=target;
Y=_mc.y;
_distance=Y-distance;
}
public function startMove():void {
_mc.addEventListener(Event.ENTER_FRAME,moves);
}
private function moves(e:Event):void {
var mc:MovieClip=e.target as MovieClip;
var dis:Number=Math.abs(mc.y-_distance)+0.2;
mc.y+=dis/4*directions;
if (mc.y<=_distance) {
directions=1;
} else if (directions==1&&mc.y>=Y) {
mc.y=Y;
directions=-1;
mc.removeEventListener(Event.ENTER_FRAME,moves);
mc.dispatchEvent(new Event("moveover"));}}}} 展开
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
public class MouseMove extends MovieClip {
private var _mc:MovieClip;
private var Y:Number;
private var _distance:Number;
private var directions:Number=-1;
public function MouseMove(target:MovieClip,distance):void {
_mc=target;
Y=_mc.y;
_distance=Y-distance;
}
public function startMove():void {
_mc.addEventListener(Event.ENTER_FRAME,moves);
}
private function moves(e:Event):void {
var mc:MovieClip=e.target as MovieClip;
var dis:Number=Math.abs(mc.y-_distance)+0.2;
mc.y+=dis/4*directions;
if (mc.y<=_distance) {
directions=1;
} else if (directions==1&&mc.y>=Y) {
mc.y=Y;
directions=-1;
mc.removeEventListener(Event.ENTER_FRAME,moves);
mc.dispatchEvent(new Event("moveover"));}}}} 展开
1个回答
展开全部
MouseMove.aspackage{进口flash.display.MovieClip;进口flash.events.Event;进口flash.events.EventDispatcher;公共类的MouseMove扩展的MovieClip{私人VAR_mc:影片剪辑;私人变种Y:数量;私人VAR_distance:数量;私人VAR方向:数=-1;公共职能的MouseMove(目标:影片剪辑,距离):无效{_mc=目标;Y =_mc.y;_distance= Y-距离;}公共职能startMove():无效{_mc.addEventListener(Event.ENTER_FRAME,移动);}私有函数的动作(E:事件):无效{VARMC:影片剪辑=e.target为影片剪辑;VARDIS:数=Math.abs(mc.y-_distance)0.2;mc.y= +DIS /4*方向;如果(mc.y<= _距离){方向= 1;}否则,如果(方向==1&&mc.y>=Y){mc.y= Y;方向= -1;mc.removeEventListener(Event.ENTER_FRAME,移动);mc.dispatchEvent(新事件(“moveover”));}}}}
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询