使用 ActionScript 3.0 组件 |
|
|
|
| 使用 UI 组件 > 使用 Label 组件 > 创建具有 Label 组件的应用程序 | |||
以下过程解释了如何在创作时将 Label 组件添加到应用程序。在此示例中,标签仅显示文本"Expiration Date"。
创建具有 Label 组件的应用程序:text 参数。
var today:Date = new Date();
var expDate:Date = addDays(today, 14);
aTa.text = expDate.toDateString();
function addDays(date:Date, days:Number):Date {
return addHours(date, days*24);
}
function addHours(date:Date, hrs:Number):Date {
return addMinutes(date, hrs*60);
}
function addMinutes(date:Date, mins:Number):Date {
return addSeconds(date, mins*60);
}
function addSeconds(date:Date, secs:Number):Date {
var mSecs:Number = secs * 1000;
var sum:Number = mSecs + date.getTime();
return new Date(sum);
}
以下示例使用 ActionScript 创建一个 Label 组件。该示例使用 Label 来标识 ColorPicker 组件的功能,并使用 htmlText 属性将格式应用于 Label 的文本。
使用 ActionScript 创建 Label 组件实例:import fl.controls.Label; import fl.controls.ColorPicker; var aLabel:Label = new Label(); var aCp:ColorPicker = new ColorPicker(); addChild(aLabel); addChild(aCp); aLabel.htmlText = '<font face="Arial" color="#FF0000" size="14">Fill:</font>'; aLabel.x = 200; aLabel.y = 150; aLabel.width = 25; aLabel.height = 22; aCp.x = 230; aCp.y = 150;
|
|
|
|