Flash:调整此代码以保留重复的影片剪辑
好的,这是我的代码
ham_mc.onPress=function(){
startDrag(this);
}
ham_mc.onRelease=ham_mc.onReleaseOutside=function(){
stopDrag();
_root.ham_mc.duplicateMovieClip("ham_mc" + "x",2);
x++;
}
用户可以首先拖动影片剪辑。释放后,duplicateMovieClip 命令将运行,在第一个拖动到的位置留下一个新的 ham 影片剪辑。
问题:当我再次单击并拖动第一个火腿影片时,duplicateMovieClip 会再次运行,但会替换以前生成的影片剪辑。
我添加了 x 和 x++ 试图每次为影片剪辑重复项指定不同的名称,但这并不能解决问题。
我如何更改此代码,以便每次都创建一个新的 ham_mc,而不是覆盖旧的。我累了,抱歉解释不好!
OK, so here is my code
ham_mc.onPress=function(){
startDrag(this);
}
ham_mc.onRelease=ham_mc.onReleaseOutside=function(){
stopDrag();
_root.ham_mc.duplicateMovieClip("ham_mc" + "x",2);
x++;
}
The user can at first drag the movie clip. When released, the duplicateMovieClip command runs, leaving a new ham movie clip in the position the first is dragged to.
PROBLEM: When I click and drag the first ham movie click again, the duplicateMovieClip runs again but REPLACES the previous generated movie clip.
I added x and x++ in an attempt to give the movie clip duplication a different name every time, but this doesn't solve it.
How do I change this code so that a NEW ham_mc is created every time, rather than overwriting the old one. I'm tired, sorry for the poor explaination!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是名称 - 而是您在 (2) 处加载它的深度。尝试用 x 替换 2,它应该适合您:
在相同深度加载剪辑将始终替换之前在该深度加载的剪辑。
编辑并测试:)
It's not the name - it's the depth that you're loading it at (2). Try replacing 2 with x and it should work for you:
Loading clips at the same depth will always replace the clip previously loaded at that depth.
Edited and tested :)
Demian 的答案是正确的,但前提是您的 x 计数与舞台上的 MovieClip 总数相匹配。此外,所有剪辑都设置为相同的 X 和 Y 位置。这应该效果更好:
Demian's answer is correct, but only if your x count matches the total number of MovieClips on the stage. Also, all clips are set to the same X and Y position. This should work better: