您的位置:首页 > Web前端 > CSS

在flex中使用CSS改变控件样式

2009-10-16 11:11 477 查看
昨天在搞一个对话框的外观 使用CSS搞定
http://www.riashanghai.com/node/7这篇文章对我帮助很大
心得写一下,自己留着好看

需要一个CSS文件,例如Default.CSS
在mxml中需要使用
<mx:Style source="Default.css"></mx:Style>
进行捆绑

对控件进行绑定
例如:控件 MyButton
需要在Default.css文件中输入和控件类名相同的项
方法一
MyButton
{
/*MC*/
upSkin:Embed(source="button.swf", symbol="up_skin");
/*PNG, BMP好像不行*/
downSkin:Embed("down_skin.png",
scaleGridLeft="10",
scaleGridRight="300",
scaleGridTop="20",
scaleGridBottom="400");
/*自定义项*/
test:"this is test string!"
}
这样就直接绑定了!
var btn:MyButton = new Mybutton();
var str:String = btn.getStyle("test");
str值就等于"this is test string!"

方法二
/*名字可以随命名*/
.MyButtonSecond
{
/*MC*/
upSkin:Embed(source="button.swf", symbol="up_skin");
/*PNG, BMP好像不行*/
downSkin:Embed("down_skin.png",
scaleGridLeft="10",
scaleGridRight="300",
scaleGridTop="20",
scaleGridBottom="400");
/*自定义项*/
test:"this is test string!"
}

flex:
<mx:MyButton xmlns:mx="http://www.adobe.com/2006/mxml" width="370" height="222" styleName="MyButtonSecond">
或者
btn.styleName = MyButtonSecond;
这样就绑定了!

比如背景色 背景图片之类的项 查文档就可以知道了或者google
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: