unity 脚本组件_Flash脚本-构建按钮组件

unity 脚本组件

Download the sample files here.

在此处下载示例文件

You can use Macromedia Flash UI components to quickly and easily add simple user interface elements to your Flash document.

您可以使用Macromedia Flash UI组件快速轻松地将简单的用户界面元素添加到Flash文档中。

In this tutorial, we’ll look at how easy it is to use the button component.

在本教程中,我们将研究使用按钮组件有多么容易。

1. Open the components panel by clicking ctrl+f7.

1.单击ctrl + f7,打开组件面板。

2. Drag the Push Button component onto the stage.

2.将“按钮”组件拖动到舞台上。

3. Select the Push Button component in Frame 1. The component’s parameters are displayed in the Property inspector.

3.在框架1中选择“按钮”组件。该组件的参数显示在“属性”检查器中。

4. To name the component, type "btn1" in the Property inspector Instance Name text box.

4.要命名组件,请在“属性检查器实例名称”文本框中键入“ btn1”。

5. Type "f1" to name the Click Handler. Later you can write ActionScript to define exactly what the Click Handler should do.

5.键入“ f1”以命名单击处理程序。 稍后,您可以编写ActionScript来确切定义Click Handler应该做什么。

1180_1

6. Select the first key frame from the existing layer, and press f9 to open the actions box.

6.从现有图层中选择第一个关键帧,然后按f9键打开操作框。

7. Insert the following action:

7.插入以下操作:

function f1(name)
{
if(name == btn1)
{btn1.setLabel("Button Pressed ")}
}

This action is simple — when you press the button, it calls the function f1().

此操作很简单-按下按钮时,它将调用函数f1()

8. The function has a parameter name which takes the Instance name of the button — in this case, btn1.

8.该函数具有一个参数名称,该参数名称采用按钮的实例名称-在这种情况下为btn1。

9. The If condition checks to see if the event is from btn1. If it is from btn1, it sets the label of button to "Button presed".

9. If条件检查该事件是否来自btn1。 如果来自btn1,它将按钮的标签设置为“按钮已设置”。

This is just a simple example. You can insert any number of events in the If block — experiment and see what you come up with!

这只是一个简单的例子。 您可以在If块中插入任意数量的事件-实验一下,然后看看结果如何!

翻译自: https://www.sitepoint.com/building-button-component/

unity 脚本组件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值