代码之家  ›  专栏  ›  技术社区  ›  Anriëtte Myburgh

flash+as2=单击movieclip时卸载movieclip本身

  •  1
  • Anriëtte Myburgh  · 技术社区  · 15 年前

    我有一个movieclip,当它被点击时会卸载另外两个movieclip。这个钻头工作得很好,但它也应该在这之后自行拆除,这尤其不起作用。这是我的代码,有人能告诉我我做错了什么吗?

    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(); // it removed the whole _root movieclip, as _root is the parent

    _parent.close_button.unloadMovie(); // did just nothing

    两者都失败了。

    3 回复  |  直到 12 年前
        1
  •  0
  •   Alex Jillard    15 年前

    在事件处理程序中, this '指的是关闭按钮,而不是主电影。您只需声明一个变量 在释放处理程序的关闭按钮之外,或尝试 this.parent.unloadMovie() (假设关闭按钮的父级是您要删除的电影)。

        2
  •  1
  •   biweevil    12 年前

    movieclip无法卸载自己,因为它无法读取不存在的代码。 它一开始不会卸载。

        3
  •  0
  •   victor hugo    15 年前

    尝试

    close_button.onRelease = function() {
        background.unloadMovie();
        loading.unloadMovie();
    
        this.removeMovieClip();  // This 'removes' the movie clip
                                 // which is the closest to 'unload'
    
    }