| |
PROGRAMMING COURSES
ADMIN VIDEO TUTORIALS
COMMUNITY RESOURCES
|
|
Flash and ActionScript 3 Tutorials - Learn Flash and ActionScript 3 |
|
|
CSS styling a Flash dynamic website Actionscript 3.0 html Text tutorial CS3+4 |
| By: Adam Created: Mar 11, 2009 Views: 18135 |
 |

| In this Flash ActionScript 3.0 tutorial suitable for Flash CS3 or CS4 you can learn how to load an external CSS style sheet to allow a dynamic text field in flash to be affected by it. A few code considerations must be met which enable the text field to properly render the CSS styles you set in the external file,and we address them in the video. There are several ways you can go about using CSS in your flash text fields... use an external file like we did in this example... set the styles directly in actionscript and do away with the need for an external CSS file... but you can choose the method that is right for you. |
ActionScript 3.0 Code Reference

var cssLoader:URLLoader;
var myText:String = "<P>Paragraph style in the external css file</P><BR>"
+ "Regular line of text, not styled.<BR>"
+ "<SPAN class=myTextStyle1>This is style 1 from external css</SPAN><BR>"
+ "<SPAN class=myTextStyle2>This is style 2 from external css</SPAN>";
function cssLoadComplete(event:Event):void {
var sheet:StyleSheet = new StyleSheet();
sheet.parseCSS(cssLoader.data);
myTextField.styleSheet = sheet;
myTextField.htmlText = myText;
}
var myTextField:TextField = new TextField();
myTextField.width = 500;
myTextField.multiline = true;
myTextField.wordWrap = true;
addChild(myTextField);
var req:URLRequest = new URLRequest("myStyleSheet.css");
cssLoader = new URLLoader();
cssLoader.addEventListener(Event.COMPLETE, cssLoadComplete);
cssLoader.load(req);
|
|