闪光灯 + AS2 = 单击时卸载影片剪辑本身
我有一个影片剪辑,单击它时会卸载另外两个影片剪辑。该位工作正常,但在此之后它也应该自行删除,这尤其不起作用。这是我的代码,有人可以告诉我我做错了什么吗:
close_button.onRelease = function() {
background.unloadMovie();
loading.unloadMovie();
this.unloadMovie();
}
问候和TIA
//编辑
这是我创建movieclips的代码:
// load background, movieclip container (loading) and close button
var background:MovieClip = _root.attachMovie("mc_back","loading_background", 100000);
var loading:MovieClip = _root.createEmptyMovieClip("loading",_root.getNextHighestDepth());
var close_button:MovieClip = _root.attachMovie("close_button","close_button",_root.getNextHighestDepth());
我尝试过:
this._parent.close_button.unloadMovie(); // 它删除了整个 _root 影片剪辑,因为 _root 是父级
和
_parent.close_button.unloadMovie(); // 什么也没做
两者都失败了。
I have a movieclip which unloads two other movieclips when it is clicked. This bit works fine, but it should also remove itself after this, which particularly does not work. Here is my code, can someone please tell me what I am doing wrong:
close_button.onRelease = function() {
background.unloadMovie();
loading.unloadMovie();
this.unloadMovie();
}
Regards and TIA
// edit
Here is the code I create the movieclips:
// load background, movieclip container (loading) and close button
var background:MovieClip = _root.attachMovie("mc_back","loading_background", 100000);
var loading:MovieClip = _root.createEmptyMovieClip("loading",_root.getNextHighestDepth());
var close_button:MovieClip = _root.attachMovie("close_button","close_button",_root.getNextHighestDepth());
I tried:
this._parent.close_button.unloadMovie(); // it removed the whole _root movieclip, as _root is the parent
and
_parent.close_button.unloadMovie(); // did just nothing
Both failed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
影片剪辑无法卸载其自身,因为它无法读取不存在的代码,因此
它首先不会卸载。
a movieclip can not unload it's self because it cannot read a code that is not there so
it does not unload in the first place.
在事件处理程序中,“
this
”将引用 close_button,而不是主影片。您需要做的就是在关闭按钮 onRelease 处理程序之外声明一个等于this
的变量,或者尝试this.parent.unloadMovie()
(假设关闭按钮是您要删除的电影)。In the event handler, '
this
' would refer to close_button, not the main movie. All you need to do is either declare a variable equal tothis
outside of the close button onRelease handler, or trythis.parent.unloadMovie()
(assuming the parent of the close button is the movie you're trying to remove).尝试
Try