Actionscript 3 如何将多个对象拖放到特定目标?
我对AS3很陌生。当然,现在可以忽略重置按钮。我知道我的代码又大又笨重,但我现在不介意,因为我很容易理解 我试着把一个黄色的球和一个黄色的球门以及绿色对绿色的比赛等等 然而,每次我尝试拖动第二个对象时,我都无法拖动,对象被卡住了,我听说这就是AS3/Flash的问题所在,唯一简单的解决方法就是将其从屏幕上拖走,这是我不想做的事情Actionscript 3 如何将多个对象拖放到特定目标?,actionscript-3,flash,Actionscript 3,Flash,我对AS3很陌生。当然,现在可以忽略重置按钮。我知道我的代码又大又笨重,但我现在不介意,因为我很容易理解 我试着把一个黄色的球和一个黄色的球门以及绿色对绿色的比赛等等 然而,每次我尝试拖动第二个对象时,我都无法拖动,对象被卡住了,我听说这就是AS3/Flash的问题所在,唯一简单的解决方法就是将其从屏幕上拖走,这是我不想做的事情 yellowBall.addEventListener(MouseEvent.MOUSE_DOWN, mouseDowny) redBall.addEventListe
yellowBall.addEventListener(MouseEvent.MOUSE_DOWN, mouseDowny)
redBall.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownr)
blueBall.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownb)
greenBall.addEventListener(MouseEvent.MOUSE_DOWN, mouseDowng)
yellowBall.addEventListener(MouseEvent.MOUSE_UP, mouseUpy)
redBall.addEventListener(MouseEvent.MOUSE_UP, mouseUpr)
blueBall.addEventListener(MouseEvent.MOUSE_UP, mouseUpb)
greenBall.addEventListener(MouseEvent.MOUSE_UP, mouseUpg)
resetButton.addEventListener(MouseEvent.CLICK, reset);
addEventListener(Event.ENTER_FRAME,enterFrameHandlerr);
function mouseDowny(event:MouseEvent):void {
yellowBall.startDrag();
}
function mouseDownr(event:MouseEvent):void {
redBall.startDrag();
}
function mouseDownb(event:MouseEvent):void {
blueBall.startDrag();
}
function mouseDowng(event:MouseEvent):void {
greenBall.startDrag();
}
function mouseUpy(event:MouseEvent):void {
yellowBall.stopDrag();
}
function mouseUpr(event:MouseEvent):void {
redBall.stopDrag();
}
function mouseUpb(event:MouseEvent):void {
blueBall.stopDrag();
}
function mouseUpg(event:MouseEvent):void {
greenBall.stopDrag();
}
function enterFrameHandlerr(event:Event):void{
if(yellowBall.hitTestObject(yellowHome)){
yellowBall.stopDrag();
yellowBall.x = int(2000);
yellowBall.y = int(60);
}
if(redBall.hitTestObject(redHome)){
redBall.stopDrag();
redBall.x = int(425);
redBall.y = int(60);
}
if(blueBall.hitTestObject(blueHome)){
blueBall.stopDrag();
blueBall.x = int(425);
blueBall.y = int(275);
}
if(greenBall.hitTestObject(greenHome)){
greenBall.stopDrag();
greenBall.x = int(55);
greenBall.y = int(275);
}
}
function reset(event:MouseEvent):void
{
yellowBall.x = int(250);
yellowBall.y = int(250);
};
你有错误吗?在每个函数中添加跟踪,并在鼠标下/上时检查是否一切正常。那么您想同时拖动多个项目吗?这是一个我以前从未听说过的想法…这里不清楚拖动第二个对象意味着什么-同时拖动?由于它似乎也被放弃了,我投票决定暂时搁置,因为还不清楚。