碰撞檢測
相對於as3中沒有press和release事件
hitTest()被分割成 hitTestPoint和hitTestObject
var check_mc=new Sprite()
this.addChild(check_mc)
//
check_mc.addEventListener(Event.ENTER_FRAME,checkFunc)
function checkFunc(evt:Event){
//檢測對象
/*
if(mc1.hitTestObject(mc2)){
trace("true")
}
*/
//檢測坐標
if(mc1.hitTestPoint(this.mouseX,this.mouseY,false)){
trace("true")
}
}
addList(mc1)
addList(mc2)
//增加事件偵聽器
function addList(mc){
mc.addEventListener("mouseDown",drag)
mc.addEventListener("mouseUp",drag)
}
//拖動
function drag(evt:MouseEvent){
var obj=evt.target
var evtType=evt.type
switch(evtType){
case "mouseDown":
obj.startDrag()
break
case "mouseUp":
obj.stopDrag()
break
}
}