简体   繁体   English

我可以在按钮上添加其他框架吗?

[英]Can I add additional frames to button ones?

I'm new in ActionScript3 and Flash. 我是ActionScript3和Flash的新手。 I would know if in the button instance (in which there are Up, Over, Down and Clicked frames, relative to upState, overState and downState) can be added other frames to call with the same method. 我想知道是否可以在按钮实例中(相对于upState,overState和downState,有Up,Over,Down和Clicked框架)可以添加其他框架以使用相同的方法进行调用。

I need something like this: 我需要这样的东西:

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

Thanks in advance! 提前致谢!

You may want to look into the SimpleButton class as it allows you to assign any DisplayObject to the different states upState , overState , downState , and hitTestState . 您可能需要研究SimpleButton类,因为它允许您将任何DisplayObject分配给不同的状态upStateoverStatedownStatehitTestState

Here's the example from Adobe's API Reference: 这是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();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Flash文件中添加重置按钮? - How can I add a reset button on a flash file? 如何仅使用as3在flex中的舞台上添加按钮? - How can I add a button to the stage in flex using only as3? 如何使用AS3永久修改框架内的对象? - How can I modify objects inside frames with AS3 in a permanent way? 如何使用ActionScript 3将变量发送到Flash中的其他框架? - How can I send a variable to other frames in Flash using ActionScript 3? 我可以使GIF动画帧在ActionScript中播放更快吗? - Can I make GIF animation frames play faster in ActionScript? 在帧中添加as3我为所有时间线或关键帧逐帧添加1帧? - add as3 in frames i add in 1 frame for all time line or key frame by key frame? 如何使用按钮从库中添加对象(使用Math.random作为位置)? - How can I add objects from the library (using Math.random for the position) using a button? 如何在Flex DataGrid嵌入式按钮itemRenderer周围添加间距? - How can I add spacing around a Flex DataGrid drop-in Button itemRenderer? 如何创建对语言环境敏感的新全局日期样式,或修改现有样式? - How can I create locale-sensitive new global date styles, or modify the existing ones? 如何动态地向时间轴添加帧? - how to add frames to timeline dynamically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM