简体   繁体   English

DropTarget ActionScript

[英]DropTarget ActionScript

i have 8 movie Clips that i stored in an array. 我有8个影片剪辑,它们存储在一个数组中。 i put the movie clips on the stage and i can move them around so everything work fine until now. 我将影片剪辑放到了舞台上,并且可以四处移动,直到现在一切正常。 I made a grid where the mc's can be droped.I saved the grid parts in an array,too. 我创建了一个网格,可以在其中放置MC。我也将网格部件保存在数组中。 after that gave names to the mc's and to the grid parts like that: mc.name= number.toString(); 之后,给mc和网格部分起了这样的名字:mc.name = number.toString(); gridpart.name= number.toString(); gridpart.name = number.toString(); the movie clips and the grid parts have the same name like: mc1.name=1 and gridpart1.name=1 and so on. 影片剪辑和网格部分的名称相同,例如:mc1.name = 1和gridpart1.name = 1,依此类推。 Now I made an if statement to check if the right mc was droped on the right grid part, like that: 现在,我做了一个if语句来检查是否将正确的mc放在了正确的网格部分上,如下所示:

if(mc.name==gridpart.name)
{
trace("correct position")
}

But nothing happens. 但是什么也没发生。 I used "dropTarget", too like that: 我也使用了“ dropTarget”:

 if(dropTarget.name==a.target.name)
{
 //code
}

I don't know what to try now. 我不知道该怎么办。 I thought to put this code in the callback function of the mouse.CLICK event handler because i want that the mc should not be moved anymore if it is on hir correct position. 我想将这段代码放在mouse.CLICK事件处理程序的回调函数中,因为我希望如果将mc放在正确的位置,也不应再移动它。 I would be happy if you have a better solution for this problem. 如果您有一个更好的解决方案,我将很高兴。 I tried to describe my problem so that you can imagine what I am trying to say. 我试图描述我的问题,以便您可以想象我要说的话。 Sorry about my English, I am not a native English speaker. 抱歉,我的英语不是我的母语。 Thank you for your time 感谢您的时间

I think you wrong using dropTarget.name . 我认为您使用dropTarget.name错了。 Try dropTarget.parent.name . 尝试dropTarget.parent.name This why dropTarget is referred to content of the DisplayObject onto which you release your dragged MovieClip. 这就是为什么dropTarget被引用到将拖动的MovieClip释放到的DisplayObject的内容的原因。 I hope this will be usefull to you! 希望对您有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM