创建仅code AS3一个按钮按钮、code

2023-09-08 14:05:58 作者:亽情世故,泠暖自知′

我觉得像这样的事情存在,但我将如何创造的只有动作脚本3 code按钮?我的意思是没有制作的形状,并把它转换为一个按钮符号或什么的。或许,这将使其更易于只是工作的FlashDevelop。

I feel like something like this exists but how would I create a button in only action script 3 code? I mean without making a shape and converting it to a button symbol or something. It would probably make it easier to only work in FlashDevelop.

推荐答案

您可以使用的SimpleButton 类或滚你自己使用雪碧类。然后,你可以画任何东西,或使用任何图像作为按钮,它结束了下来默认状态。

You can use the SimpleButton class or roll your own using the Sprite class. Then you can draw anything or use any image as the button and it's over down default states.

例如一个简单的按钮可以是这样的:

For example a simple button can be like this :

var goButton:SimpleButton = new SimpleButton();

var myButtonSprite:Sprite = new Sprite();
myButtonSprite.graphics.lineStyle(1, 0x555555);
myButtonSprite.graphics.beginFill(0xff000,1);
myButtonSprite.graphics.drawRect(0,0,200,30);
myButtonSprite.graphics.endFill();

goButton.overState = goButton.downState = goButton.upState = goButton.hitTestState = myButtonSprite;
addChild(goButton);

您可以有不同的显示对象的按钮的每个状态,或者你可以将位图,而不是精灵。

You can have different display objects for each state of the button or you can attach bitmaps instead of sprites.