现在的位置: 首页 > 综合 > 正文

每天学点AS3-7

2013年10月09日 ⁄ 综合 ⁄ 共 880字 ⁄ 字号 评论关闭

每天学点AS3-7

14,SimpleButton实例

AS3现在有一个新的类:SimpleButton(flash.display.SimpleButton)。这个类允许你通过AS创建一个按钮。

 
 

var myButton:SimpleButton = new SimpleButton();

SimpleButton类有4个属性分别代表按钮的四个不同状态:upState,overState,downState和hitAreaState。你可以为每一个状态创建一个新的显示对象,然后将显示对象赋予SimpleButton的各种状态:

myButton.upState = mySprite1;
myButton.overState = mySprite2;
myButton.downState = mySprite3;
myButton.hitAreaState = mySprite4;

15,数组定义中的逗号

本文非直接翻译,原文解释部分如下:
When defining arrays in ActionScript 3 using the shorthand array access operator (brackets), you can now have a trailing comma following the last element without causing an error (like in PHP). This makes working with multi-line array definitions a little less error-prone when rearranging elements.

先来看一个例子:

var myList:Array = [
    "The",
    "quick",
    "brown",
    "fox",
];

在AS1和2中,"fox"后的逗号会导致一个编译错误,但是在AS3中不会了。

注意,这个逗号只是在使用[]定义数组的时候有效,使用Array()或new Array()的时候是无效的。

抱歉!评论已关闭.