StyleManager类的StyleManager.loadStyleDeclarations() 方法.
示例:


代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/12/loading-cascading-style-sheets-on-the-fly-using-the-flex-stylemanager-class/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle">

    
<mx:Script>
        
<![CDATA[
            import mx.styles.StyleManager;

            private function loadStyles(styleURL:String):void {
                StyleManager.loadStyleDeclarations(styleURL);
            }
        
]]>
    
</mx:Script>

    
<mx:ApplicationControlBar dock="true">
        
<mx:ComboBox id="comboBox"
                prompt
="Please select a style"
                change
="loadStyles(comboBox.selectedItem.data);">
            
<mx:dataProvider>
                
<mx:Array>
                    
<mx:Object label="red" data="styles/red.swf" />
                    
<mx:Object label="green" data="styles/green.swf" />
                    
<mx:Object label="blue" data="styles/blue.swf" />
                
</mx:Array>
            
</mx:dataProvider>
        
</mx:ComboBox>
    
</mx:ApplicationControlBar>

</mx:Application>

相关文章:

  • 2022-01-05
  • 2021-08-05
  • 2021-09-01
  • 2021-05-25
  • 2021-12-05
  • 2021-05-30
  • 2021-12-16
  • 2022-01-31
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2021-06-17
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案