---
title: "flex 样式"
author: "wangguangji"
date: "2011-10-12T16:08:38Z"
tags: []
categories: ["Web前端"]
slug: "flex"
draft: false
lastmod: "2011-10-12T16:08:38Z"
id: 1190834
url: "https://wangxingrang.iteye.com/blog/1190834"
---

用flex sdk提供的mxmlc工具将你的CSS文件打包，然后利用mx.styles.StyleManager的运行时加载CSS文件。
编辑时加载样式使你不需要重新编译即可改变样式定义。若要在运行时加载swf，你要使用styleManager的loadStyleDeclarations方法。

```java

var dispathcher:IEventDispatcher = StyleManager.loadStyleDeclarations("文件路径",true);
dispathcher.addEventListener(StyleEvent.complete,styleCompleteHandler);


private function styleCompleteHandler(evt:styleEvent){}


```