Right now, I successfully loaded a body of text into my movie from an external text file and a css file. However, when I test my movie, the text wouldn’t load at the first click. And I get this error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at about_fla::MainTimeline/frame1()
But then it loads at the second click without any error messages. Does any know why this is happening?
Also, I saw the “Write On Text Effect” tutorial at http://www.gotoandlearn.com. But it seems like it’s for actionscript 2. Does anyone know how can I convert this into actionscript 3 and apply it to my existing code?
Thank you so much!
import flash.text.TextField;
import flash.text.StyleSheet;
var textfield:TextField = new TextField();
textfield.width = 800;
textfield.height = stage.stageHeight;
textfield.wordWrap = true;
textfield.autoSize = TextFieldAutoSize.LEFT;
textfield.selectable = false;
addChild(textfield);
var wordList:Array = new Array();
var textLoader:URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE, textLoaded);
var cssLoader:URLLoader = new URLLoader();
var css:StyleSheet = new StyleSheet();
function cssLoaded(e:Event):void{
css.parseCSS(e.target.data);
textfield.styleSheet = css;
for(var i:int = 0; i < wordList.length; i++){
textfield.htmlText += "<h4>" + wordList* + "</h4>";
}
}
function textLoaded(e:Event):void{
wordList = e.target.data.split("
");
cssLoader.load(new URLRequest("about.css"));
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
}
textLoader.load(new URLRequest("about.txt"));