문제

Here's a simple code of rectangle drawing by mouse,and I'm going to add code for draging.but I encounter an error
Error #1069: Property CLICK not found on flash.events.MouseEvent and there is no default value.

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");
}
도움이 되었습니까?

해결책

Just use this syntax for your event handlers:

function mUp( e:MouseEvent ){

And:

function mDown( e:MouseEvent ){
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top