Tutorial for Using CSS in Flash

This tutorial is based on one written by Neil Webb in 2005. It was the best one I could find. I also appreciated the list of supported CSS selectors published by Todd Dominey in 2003. See also my Tutorial for Using CSS with XML in Flash.

Below is a SWF embedded in this page. The text is selectable. All the text you see is formatted via an external CSS style sheet (see the style sheet).

The biggest drawback: No space is added automatically between paragraphs, and you cannot add any vertical space with padding or with margin. This is a very big flaw!

The biggest benefit: You can style your links to behave just like HTML links ought to behave! This is excellent.

To play with these files, download the FLA (48 KB) and the CSS file (1 KB). That is all you need. The ActionScript to load the CSS file is all in Frame 1 in the top layer.

This tutorial assumes that you already know how to: (a) write CSS; (b) create a text field with dynamic text in Flash; and (c) write ActionScript in Flash. This method should work in Flash MX 2004, Flash 8, and all later versions of Flash. It will work with ActionScript 1.0 and 2.0. The version you see above was saved for Flash Player 7.