上一篇是讲到,按钮有浮雕效果,并且怎样让标签字体变的更加清晰.今天继续.
-------------------------------------------------------------------------------------------
进一步了解按钮中的图标 1
import fl.controls.Button;
import fl.controls.ButtonLabelPlacement;
var sheepLeft:Button = new Button();
sheepLeft.label = "羊在左";
sheepLeft.labelPlacement = ButtonLabelPlacement.LEFT;
sheepLeft.setStyle("icon", sheep);
sheepLeft.setSize(200, 40);
sheepLeft.move(10, 10);
addChild(sheepLeft);
var sheepRight:Button = new Button();
sheepRight.label = "羊在右";
sheepRight.labelPlacement = ButtonLabelPlacement.RIGHT;
sheepRight.setStyle("icon", sheep);
sheepRight.setSize(200, 40);
sheepRight.move(10, 60);
addChild(sheepRight);
var sheepBottom:Button = new Button();
sheepBottom.label = "羊在下";
sheepBottom.labelPlacement = ButtonLabelPlacement.TOP;
sheepBottom.setStyle("icon", sheep);
sheepBottom.setSize(200, 60);
sheepBottom.move(10, 120);
addChild(sheepBottom);
var sheepTop:Button = new Button();
sheepTop.label = "羊在上";
sheepTop.labelPlacement = ButtonLabelPlacement.BOTTOM;
sheepTop.setStyle("icon", sheep);
sheepTop.setSize(200, 60);
sheepTop.move(10, 190);
addChild(sheepTop);
讲解: 要上ICO起作用首先要为在库里的ICON 图标Linkage.接着就是调整
labelPlacement的属性了,要先导入ButtonLabelPlacement,只要相对与图标的位置就行了.
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
进一步了解按钮中的图标 2
import fl.controls.Button;
import fl.controls.ButtonLabelPlacement;
var sheepNear:Button = new Button();
sheepNear.label = "羊很近";
sheepNear.labelPlacement = ButtonLabelPlacement.LEFT;
sheepNear.setStyle("icon", sheep);
sheepNear.setSize(200, 40);
sheepNear.move(10, 10);
addChild(sheepNear);
var sheepFar:Button = new Button();
sheepFar.label = "羊很远";
sheepFar.labelPlacement = ButtonLabelPlacement.LEFT;
sheepFar.setStyle("icon", sheep);
sheepFar..setStyle("textPadding", 45);
sheepFar.setSize(200, 40);
sheepFar.move(10, 60);
addChild(sheepFar);
讲解:要让文字与图标保持距离就简单了,只要加上
setStyle("textPadding", 距离),就搞定了。简单.
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
进一步了解按钮中的图标 3
import fl.controls.Button;
import fl.controls.CheckBox;
var myButton:Button = new Button();
myButton.label = "icons";
myButton.enabled = true;
myButton.toggle = true;
myButton.setStyle("upIcon", BulletCheck);
myButton.setStyle("overIcon", BulletWarning);
myButton.setStyle("downIcon", BulletCritical);
myButton.setStyle("disabledIcon", IconCheck);
myButton.setStyle("selectedUpIcon", BulletCheckSelected);
myButton.setStyle("selectedOverIcon", BulletWarningSelected);
myButton.setStyle("selectedDownIcon", BulletCriticalSelected);
myButton.setStyle("selectedDisabledIcon", IconCheckSelected);
myButton.setSize(120, 40);
myButton.move(10, 10);
addChild(myButton);
var enabledCheckBox:CheckBox = new CheckBox();
enabledCheckBox.label = "enabled";
enabledCheckBox.selected = myButton.enabled;
enabledCheckBox.move(10, 60);
enabledCheckBox.addEventListener(Event.CHANGE, enabledChangeHandler);
addChild(enabledCheckBox);
var toggleCheckBox:CheckBox = new CheckBox();
toggleCheckBox.label = "toggle";
toggleCheckBox.selected = myButton.toggle;
toggleCheckBox.move(10, 80);
toggleCheckBox.addEventListener(Event.CHANGE, toggleChangeHandler);
addChild(toggleCheckBox);
function enabledChangeHandler(event:Event):void {
myButton.enabled = enabledCheckBox.selected;
}
function toggleChangeHandler(event:Event):void {
myButton.toggle = toggleCheckBox.selected;
}