我设置了按钮的标签和皮肤,但是当我尝试添加代码以随机化皮肤时,皮肤工作正常,但标签消失了。如果我删除 button1.setStyle("skinClass", randomSkin()); 显示标签。
public function randomSkin():Class{
var randSkin:Array = new Array(Skins.Normal,Skins.Ice,Skins.Fire,Skins.Jewel,Skins.Stone);
var index:Number=Math.floor(Math.random()*randSkin.length);
return randSkin[index];
}
button1.setStyle("skinClass", randomSkin());
button1.label=tiles[0][0];
当我尝试跟踪按钮的标签时,它有一个值,但它没有显示在按钮上。
如何在按钮上显示标签?
这是我使用的皮肤代码之一
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width.down="100%" height.down="100%">
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.Button")]
</fx:Metadata>
<!-- states -->
<s:states>
<s:State name="disabled" />
<s:State name="down" />
<s:State name="over" />
<s:State name="up" />
</s:states>
<s:BitmapImage includeIn="disabled" left="0" right="0" top="0" bottom="0"
source="@Embed('assets/textures/tiles/fire.png')"/>
<s:BitmapImage includeIn="down" left="0" right="0" top="0" bottom="0" blendMode="difference"
source="@Embed('assets/textures/tiles/fire.png')"/>
<s:BitmapImage includeIn="over" left="0" right="0" top="0" bottom="0"
source="@Embed('assets/textures/tiles/fire.png')"/>
<s:BitmapImage includeIn="up" left="0" right="0" top="0" bottom="0"
source="@Embed('assets/textures/tiles/fire.png')"/>
<s:Group id="contentGroup" top="52" left="5" right="5"/>
</s:Skin>