删除目标动作脚本
我有 8 个电影剪辑,存储在一个数组中。我把电影剪辑放在舞台上,我可以移动它们,所以到目前为止一切都工作正常。我制作了一个可以放置 mc 的网格。我也将网格部分保存在数组中。 之后给MC和网格部分命名,如下所示: mc.name=number.toString(); gridpart.name=number.toString(); 影片剪辑和网格部件具有相同的名称,例如:mc1.name=1 和 gridpart1.name=1 等。 现在我做了一个 if 语句来检查正确的 mc 是否被放到了正确的网格部分,就像这样:
if(mc.name==gridpart.name)
{
trace("correct position")
}
但是什么也没有发生。我也使用了“dropTarget”:
if(dropTarget.name==a.target.name)
{
//code
}
我不知道现在该尝试什么。我想将此代码放入 mouse.CLICK 事件处理程序的回调函数中,因为我希望如果 mc 位于正确的位置,则不应再移动它。 如果您对这个问题有更好的解决方案,我会很高兴。 我试图描述我的问题,以便您可以想象我想说的内容。 抱歉我的英语,我的母语不是英语。 谢谢您的宝贵时间
i have 8 movie Clips that i stored in an array. 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.
after that gave names to the mc's and to the grid parts like that:
mc.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.
Now I made an if statement to check if the right mc was droped on the right grid part, like that:
if(mc.name==gridpart.name)
{
trace("correct position")
}
But nothing happens. I used "dropTarget", too like that:
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.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您使用
dropTarget.name
是错误的。尝试dropTarget.parent.name
。这就是为什么 dropTarget 引用了您将拖动的 MovieClip 释放到其上的 DisplayObject 的内容。我希望这对您有用!
I think you wrong using
dropTarget.name
. TrydropTarget.parent.name
. This why dropTarget is referred to content of the DisplayObject onto which you release your dragged MovieClip.I hope this will be usefull to you!