如何创建可拖动的mc?下面就来看看利用as 3.0 创建可拖动的mc的一代码,注明本文来自网络.
package com.sxl001{
  import .display.Sprite;
  import flash.events.MouseEvent;
  public class DragMc extends Sprite {
    private var circle:Sprite;
    private var begin:Boolean;
    private var dx:Number;//用于计算MouseX与圆的x位置差的变量
    private var dy:Number;//用于计算MouseY与圆的y位置差
    public function DragMc() {
      begin=false;
      init();
    }
    private function init() {
      circle=new Sprite();
      addChild(circle);
      circle.graphics.beginFill(0xFF0000);
      circle.graphics.drawCircle(0,0,20);
      circle.graphics.endFill();
      circle.x=stage.stageWidth/2-circle.width/2;
      circle.y=stage.stageHeight/2-circle.height/2;
      circle.addEventListener(MouseEvent.MOUSE_DOWN,onMD);
      circle.addEventListener(MouseEvent.MOUSE_MOVE,onMM);
      circle.addEventListener(MouseEvent.MOUSE_UP,onMU);
    }
    private function onMD(ev:MouseEvent) {
      dx=stage.mouseX-circle.x;//计算MouseX与圆的x位置差
      dy=stage.mouseY-circle.y;//计算MouseY与圆的y位置差
      begin=true;
    }
    private function onMM(ev:MouseEvent) {
      if (begin) {//圆跟随Mouse
        circle.x=stage.mouseX-dx;
        circle.y=stage.mouseY-dy;
      }
    }
    private function onMU(ev:MouseEvent) {
      begin=false;
    }
  }
}
 
                        模拟极限越野
模拟极限越野开着大巴在各种奇葩路况里送乘客。山路弯道多得让人
 
                        模拟火车
模拟火车让你当回真正的火车司机,得先学会看信号灯、操作控制杆
 
                        可口的披萨美味的披萨
可口的披萨美味的披萨带您体验经营一家披萨店的乐趣。游戏画风温
 
                        定制虚拟偶像最新版
定制虚拟偶像最新版是一款超级经典有趣的日本模拟装扮类型的手游
 
                        病娇模拟器手机版正版(yandere simulator)
病娇模拟器最新版手游是一款萌妹二次元模拟游戏,玩家在游戏中可