这是一个用鼠标绘制矩形的简单代码,我将为draging添加代码。但是我遇到错误
错误#1069:在flash.events.MouseEvent上找不到属性CLICK,并且没有默认值。
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");
}
答案 0 :(得分:1)
只需将此语法用于事件处理程序:
function mUp( e:MouseEvent ){
和
function mDown( e:MouseEvent ){