我想点击它时隐藏闪光灯中的按钮

时间:2015-01-20 14:15:16

标签: flash actionscript

朋友们,我想创建一个flash练习。当我点击它时它应该隐藏或消失。

on (release) {
{
setProperty("button1",_visible,false);
}
}

1 个答案:

答案 0 :(得分:0)

setProperty函数的使用方式如下:

setProperty(target:Object, property:Object, expression:Object) : Void

因此target可以是对象本身或其名称,因为您位于按钮的时间轴内,所以不能像在代码中那样直接使用其名称。

为了让你的对象在时间轴内,你有很多礼貌,所以你可以这样做:

// In my case, the button1 object is inside the root timeline

on (release) {

    // you can use some traces to more understand

    trace(_parent);                     // gives : _level0
    trace(this._parent);                // gives : _level0      
    // this._parent is the same as _parent inside the timeline of our object        

    trace(this);                        // gives : _level0.button1

    // if you want to use the name of your object inside its timeline, you have to use it on reference with its parent 
    trace(this._parent[this._name]);    // gives : _level0.button1
    trace(this._parent['button1']);     // gives : _level0.button1
    trace(this._parent.button1);        // gives : _level0.button1

    // then you can pick a choice between all these notation : 

    var _this = this._parent['button1'];// this, this._parent[this._name] or this._parent.button1

    // to hide the object using setProperty
    setProperty(_this, _visible, false);

    // or simply without setProperty 
    _this._visible = false;

}

如果你在对象parent的时间轴内,你可以这样做:

button1.onRelease = function():Void {

    // to hide the object using setProperty, you can do
    setProperty(this, _visible, false);

    // or ( selected by its name )
    setProperty(this._name, _visible, false);

    // or ( selected by its name )
    setProperty('button1', _visible, false);

    // or
    setProperty(button1, _visible, false);

    // or simply without setProperty 
    this._visible = false;

    // or
    button1._visible = false;

    // or, using its name 
    this._parent[this._name]._visible = false;
    this._parent['button1']._visible = false;
    this._parent[button1]._visible = false;

}

我知道我的回答可能会更短,但我试图澄清事情以便更加理解。

希望可以提供帮助。