创建仅code AS3一个按钮 [英] Create a Button with only code AS3

查看:163
本文介绍了创建仅code AS3一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得像这样的事情存在,但我将如何创造的只有动作脚本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.

这篇关于创建仅code AS3一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆