2011-01-14 56 views
0
ham_mc.onPress=function(){ 
startDrag(this); 
_root.ham_mc.swapDepths(getNextHighestDepth()); 
} 
ham_mc.onRelease=ham_mc.onReleaseOutside=function(){ 
stopDrag(); 
_root.ham_mc.duplicateMovieClip("ham_mc"+x,_root.getNextHighestDepth()); 
x++ 
} 

这段代码只是生成一个新的ham_mc,其中用户释放原始(拖放)。原始回报到它的起点。我有一个名为cheese_mc的movieclip的代码,用户也可以拖放干酪。删除duplicateMovieClip的最佳方法是什么?

因此,如果创建了这些ham_mc和cheese_mc中的一个以上,删除最后一个创建的最好方法是什么?

我想要一个简单的按钮,我们称之为delete_mc。按下该按钮,颠倒最后一次duplicateMovieClip动作。我如何实现这一点?

回答

1

将上次创建的MovieClip存储在变量中。然后使用removeMovieClip();

_root.lastClip = null; 

ham_mc.onPress=function(){ 
    startDrag(this); 
    _root.ham_mc.swapDepths(getNextHighestDepth()); 
} 
ham_mc.onRelease=ham_mc.onReleaseOutside=function(){ 
    stopDrag(); 
    _root.lastClip = _root.ham_mc.duplicateMovieClip("ham_mc"+x,_root.getNextHighestDepth()); 
    x++; 
} 

delete_mc.onRelease = function() { 
    if (_root.lastClip != null) _root.lastClip.removeMovieClip(); 
} 
+0

看起来不错我会尽快测试。谢谢。 – 2011-01-14 22:55:59

相关问题