我可以在按钮上添加额外的框架吗?



我是ActionScript3和Flash的新手。我知道在按钮实例(其中有向上、超过、向下和单击的帧,相对于上州、超州和下州)是否可以添加其他帧以使用相同的方法调用。

我需要这样的东西:

if(...){
Button.upState = Button.MyOwnFrame;
}

提前感谢!

你可能

想看看SimpleButton类,因为它允许你将任何DisplayObject分配给不同的状态upStateoverStatedownStatehitTestState

以下是 Adobe API 参考中的示例:

package {
    import flash.display.Sprite;
    public class SimpleButtonExample extends Sprite {
        public function SimpleButtonExample() {
            var button:CustomSimpleButton = new CustomSimpleButton();
            addChild(button);
        }
    }
}
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.SimpleButton;
class CustomSimpleButton extends SimpleButton {
    private var upColor:uint   = 0xFFCC00;
    private var overColor:uint = 0xCCFF00;
    private var downColor:uint = 0x00CCFF;
    private var size:uint      = 80;
    public function CustomSimpleButton() {
        downState      = new ButtonDisplayState(downColor, size);
        overState      = new ButtonDisplayState(overColor, size);
        upState        = new ButtonDisplayState(upColor, size);
        hitTestState   = new ButtonDisplayState(upColor, size * 2);
        hitTestState.x = -(size / 4);
        hitTestState.y = hitTestState.x;
        useHandCursor  = true;
    }
}
class ButtonDisplayState extends Shape {
    private var bgColor:uint;
    private var size:uint;
    public function ButtonDisplayState(bgColor:uint, size:uint) {
        this.bgColor = bgColor;
        this.size    = size;
        draw();
    }
    private function draw():void {
        graphics.beginFill(bgColor);
        graphics.drawRect(0, 0, size, size);
        graphics.endFill();
    }
}

最新更新