这是一个简单的用鼠标绘制矩形的代码,我将添加用于拖动的代码。但是我遇到错误
Error #1069: Property CLICK not found on flash.events.MouseEvent 并且没有默认值。
import flash.events.MouseEvent;
import flash.display.MovieClip;
var mouseHolding:Boolean=false;
var posx:Number,posy:Number
stage.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
stage.addEventListener(MouseEvent.MOUSE_UP, mUp);
function mDown(MouseEvent){
mouseHolding=true;
posx=mouseX;
posy=mouseY;
}
function mUp(MouseEvent){
mouseHolding=false;
var myDraw:MovieClip= new MovieClip();
myDraw.graphics.lineStyle(2, 0x000000, 1);
myDraw.graphics.beginFill(0x222222, 0.5);
myDraw.graphics.drawRect(posx, posy, mouseX-posx, mouseY-posy);
myDraw.graphics.endFill();
addChild(myDraw);
//problem line
myDraw.addEventListener(MouseEvent.CLICK,objclick)}
function objclick(e:MouseEvent) {
trace("fine");
}