removeMovieClip 无效的解决办法

本文探讨了在使用Flash时遇到的问题,即使用removeMovieClip函数无法删除影片剪辑的情况。通过调整影片剪辑的附加方式,成功解决了该问题,并讨论了组件、getNextHighestDepth方法与DepthManager之间的关系。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天用 removeMovieClip 这个函数死活删不了影片剪辑.

我生成影片剪辑的语句是这样:

_root.attachMovie("my_node", "my_node"+node_num, _root.getNextHighestDepth());

 后来改成;

_root.attachMovie("my_node", "my_node"+node_num, 1000+node_num);

就能正常删除影片剪辑了.

网上搜了一下,发现一个链接:

http://kyle.jolin.info/tt/index.php?pl=267&ct1=2

其实讲的是removeMovieClip , getNextHighestDepth  ,  DepthManager  , 1048574界限  以及  组件 的关系;

原来我的fla文件里面用到一个textInput组件,如果用了组件,并且代码里面还有getNextHighestDepth,那么removeMovieClip 将不能正常删除影片剪辑.

其实flash的内置帮助里面已经提到:

"如果您的 SWF 文件包括第 2 版的组件,请使用第 2 版的组件的 DepthManager 类而不是MovieClip.getNextHighestDepth() 方法。"

只是我一直不清楚所谓的"第2版"组件是什么意思.....对DepthManager 也不了解.

呵呵,本来flash里面的层就很难理解了,再多个DepthManager,更烦,最好 ActionStript3 里面不要搞这么复杂...

 

for (var i = 1; i <= 9; i++) { var img_mc:MovieClip = this["tu" + i]; // 添加点击事件监听器 img_mc.onPress = function() { // 创建该图像的副本,并将其设置为可拖动 var target_mc:MovieClip = this.duplicateMovieClip(this._name + "_copy", _root.getNextHighestDepth()); target_mc.startDrag(); target_mc.onPress = function() { this.startDrag(); }; // 在鼠标移动事件处理程序中,将图像的位置设置为鼠标位置 target_mc.onMouseMove = function() { if(Key.isDown(Key.H)) { // 从舞台上删除该剪辑 this.removeMovieClip(); return; this._x = _root._xmouse; this._y = _root._ymouse; } // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } target_mc._alpha = 100; }; // 在鼠标释放事件处理程序中,检查图像是否与其他图像重叠 target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); this.onMouseMove = null; target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); }; // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } // 将图像放置在当前位置,并将其透明度设置为100% target_mc._alpha = 100; target_mc.swapDepths(_root.getNextHighestDepth()); }; }; }运行时提示没有h的属性 要怎么做
05-24
for (var i = 1; i <= 9; i++) { var img_mc:MovieClip = this["tu" + i]; // 添加点击事件监听器 img_mc.onPress = function() { // 创建该图像的副本,并将其设置为可拖动 var target_mc:MovieClip = this.duplicateMovieClip(this._name + "_copy", _root.getNextHighestDepth()); target_mc.startDrag(); target_mc.onPress = function() { this.startDrag(); }; // 在鼠标移动事件处理程序中,将图像的位置设置为鼠标位置 target_mc.onMouseMove = function() { if (Key.getCode() == 72) { // H键的ASCII码值为72 // 从舞台上删除该剪辑 this.removeMovieClip(); return; this._x = _root._xmouse; this._y = _root._ymouse; } // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } target_mc._alpha = 100; }; // 在鼠标释放事件处理程序中,检查图像是否与其他图像重叠 target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); this.onMouseMove = null; target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); }; // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } // 将图像放置在当前位置,并将其透明度设置为100% target_mc._alpha = 100; target_mc.swapDepths(_root.getNextHighestDepth()); }; }; } 检测不到我按下h键
05-24
for (var i = 1; i <= 9; i++) { var img_mc:MovieClip = this["tu" + i]; // 添加点击事件监听器 img_mc.onPress = function() { // 创建该图像的副本,并将其设置为可拖动 var target_mc:MovieClip = this.duplicateMovieClip(this._name + "_copy", _root.getNextHighestDepth()); target_mc.startDrag(); target_mc.onPress = function() { this.startDrag(); }; // 在鼠标移动事件处理程序中,将图像的位置设置为鼠标位置 target_mc.onMouseMove = function() { if (Key.getCode() == 72) { // H键的ASCII码值为72 // 从舞台上删除该剪辑 this.removeMovieClip(); return; } this._x = _root._xmouse; this._y = _root._ymouse; // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } target_mc._alpha = 100; }; // 在鼠标释放事件处理程序中,检查图像是否与其他图像重叠 target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); this.onMouseMove = null; target_mc.onRelease = target_mc.onReleaseOutside = function () { this.stopDrag(); }; // 检查图像是否与其他图像重叠,并根据需要更新其透明度 for (var j = 1; j <= 9; j++) { var other_mc:MovieClip = _root["tu" + j]; if (target_mc != other_mc && target_mc.hitTest(other_mc)) { target_mc._alpha = 50; return; } } // 将图像放置在当前位置,并将其透明度设置为100% target_mc._alpha = 100; target_mc.swapDepths(_root.getNextHighestDepth()); }; }; 我按下h键时 副本图片没有被删除
05-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值