|
Text Enhancement / using styles and HTML pages in Flash When we say we are enhancing text in flash by implementing ‘styles’ to it, We certainly mean we have a styles (.css) page and an HTML page, which is loaded into flash.
To Begin with, create an external styles page and an HTML page. - Using dreamweaver, I created a styles page (styles.css) with style tags I require for my text formatting / enhancement.
- Then I created an HTML page. Retained only body tag, deleted other tags like "<html> and <head>".
- Insert text and styles in body tag.
Now coming back to flash file, - I imported background image which I had created in Fireworks and placed it as background.
- Then I created a Dynamic text field and gave an instance name ‘content_txt’.
- To begin with actionscript,
Create a new layer and name it ‘actions’. Select ‘Frame1’ of this ‘actions’ layer and paste the below script in actions window. If your actions window is not open, press ‘F9’ or select ‘Windows > Actions’ from menu bar.
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
myStyle.load("styles.css"); content_txt.styleSheet = myStyle; content_txt.multiline= true; content_txt.wordWrap = true; content_txt.html = true;
var story:XML = new XML(); story.ignoreWhite = true; story.load("content.html"); story.onLoad = function () { content_txt.htmlText = story; } |
Code above, you see,
story.ignoreWhite = true; | Which is used to prevent white space such as tabs and spaces used in formatting in your XML to be interpreted as text nodes
Now all you will have to do is test your file, : ). Yes, exactly, this tutorial ends here. Isn’t it simple to enhance text in flash. Click here to download source file
Tags : Text Enhancement in flash, CSS in Flash, Import HTML page in Flash , CSS
and HTML in Flash
|