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

styleManager动态改变样式

2009-03-05 17:52 260 查看
http://www.freesitesource.com/2009/0305/542.html

<?xml version="1.0"?>

<!-- containers\layouts\MainMyLoginForm.mxml -->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Style>

.myStyle {

color: red;

}

</mx:Style>

<mx:Script><![CDATA[

import mx.styles.StyleManager;

public function initApp(e:Event):void {

/* Type selector; applies to all Buttons and subclasses of Button. */

StyleManager.getStyleDeclaration("Button").setStyle("fontSize",24);

/* Class selector; applies to controls using the style

named myStyle. Note that class selectors must be prefixed

with a period. */

StyleManager.getStyleDeclaration(".myStyle").setStyle("color",0xCC66CC);

/* Global style: applies to all controls. */

StyleManager.getStyleDeclaration("global").setStyle("fontStyle","italic");

}

private function changebt(evt:MouseEvent):void

{

StyleManager.getStyleDeclaration(".myStyle").setStyle("color",0xffff00);

}

]]></mx:Script>

<mx:Button id="myButton" click="changebt(event)" label="Click Me" styleName="myStyle"/>

<mx:Label id="myLabel" text="This is a label." styleName="myStyle"/>

</mx:Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: