1

這是一個簡單的鼠標矩形繪圖代碼,我要爲draging添加代碼。但我遇到了錯誤
錯誤#1069:屬性CLICK not在flash.events.MouseEvent上找到並且沒有默認值。錯誤#1069屬性CLICK找不到...不能addeventlistener

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"); 
} 

回答

1

只要使用此語法您的事件處理程序:

function mUp(e:MouseEvent){ 

和:

function mDown(e:MouseEvent){ 
+0

這樣一個簡單的錯誤,我無法找到it.sigh .....我從任何地方複製繪圖代碼,爲了繪畫的目的,它沒有問題,但沒有注意到這一點,但thx.It也是自己的基本事情的錯......... – sbk201

+0

@ sbk201沒關係,我們是在這裏互相幫助! – Cherniv

相關問題