Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 我可以为按钮添加其他帧吗?_Actionscript 3_Flash_Button_Frames_Simplebutton - Fatal编程技术网

Actionscript 3 我可以为按钮添加其他帧吗?

Actionscript 3 我可以为按钮添加其他帧吗?,actionscript-3,flash,button,frames,simplebutton,Actionscript 3,Flash,Button,Frames,Simplebutton,我是ActionScript3和Flash的新手。 我知道在button实例中(其中有Up、Over、Down和Clicked帧,相对于Up State、overState和downState),是否可以添加其他帧以使用相同的方法调用 我需要这样的东西: if(...){ Button.upState = Button.MyOwnFrame; } 提前谢谢 您可能需要查看该类,因为它允许您将任何DisplayObject分配给不同的状态upState、overState、downsttate和

我是ActionScript3和Flash的新手。 我知道在button实例中(其中有Up、Over、Down和Clicked帧,相对于Up State、overState和downState),是否可以添加其他帧以使用相同的方法调用

我需要这样的东西:

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

提前谢谢

您可能需要查看该类,因为它允许您将任何
DisplayObject
分配给不同的状态
upState
overState
downsttate
hitTestState

以下是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();
    }
}

不,我想你不行。