闪光灯 + AS2 = 单击时卸载影片剪辑本身

发布于 2024-08-05 15:22:27 字数 858 浏览 9 评论 0原文

我有一个影片剪辑,单击它时会卸载另外两个影片剪辑。该位工作正常,但在此之后它也应该自行删除,这尤其不起作用。这是我的代码,有人可以告诉我我做错了什么吗:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

追星践月 2024-08-12 15:22:27

影片剪辑无法卸载其自身,因为它无法读取不存在的代码,因此
它首先不会卸载。

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.

漫漫岁月 2024-08-12 15:22:27

在事件处理程序中,“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 to this outside of the close button onRelease handler, or try this.parent.unloadMovie() (assuming the parent of the close button is the movie you're trying to remove).

(り薆情海 2024-08-12 15:22:27

尝试

close_button.onRelease = function() {
    background.unloadMovie();
    loading.unloadMovie();

    this.removeMovieClip();  // This 'removes' the movie clip
                             // which is the closest to 'unload'

}

Try

close_button.onRelease = function() {
    background.unloadMovie();
    loading.unloadMovie();

    this.removeMovieClip();  // This 'removes' the movie clip
                             // which is the closest to 'unload'

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文