1

这是一个简单的用鼠标绘制矩形的代码,我将添加用于拖动的代码。但是我遇到错误
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");
}
4

1 回答 1

1

只需将此语法用于您的事件处理程序:

function mUp( e:MouseEvent ){

和:

function mDown( e:MouseEvent ){
于 2013-10-20T16:04:42.790 回答