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>
<?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>
相关文章推荐
- [VB.NET]vb.net 根据数据情况动态改变datagrid样式(急)
- 用C#代码动态改变页面样式
- 使用jquery.fullpage.js需要动态改变导航小圆点的样式
- 网页中动态改变样式
- 使用javascript动态改变当前行的显示样式
- 微信小程序 动态改变样式
- jQuery实现鼠标滚轮动态改变样式或效果
- 用C#代码动态改变页面样式
- angularJs中的ng-class动态改变样式
- 动态改变样式,如,readOnly, display
- 使用js改变DOM样式的三种方式 - 动态创建style标签
- 如何在网页中动态改变样式
- 用C#代码动态改变页面样式
- 如何在网页中动态改变样式
- win8,win8.1中怎样动态地改变listview的模板样式
- Silverlight4 动态改变界面的样式
- 网页中动态改变样式
- [iOS开发]TextKit之动态改变样式
- angularJs中ng-style动态改变样式
- AngularJS使用ng-style动态改变样式