2 Replies Latest reply on Aug 27, 2007 4:42 AM by RGracia

    Loading text files info Text Fields on AS3

    RGracia Level 1
      Hey guys, I am following some examples from Flash CS3 Help files and some portions of the ActionScript 3.0 Cookbook on TextFields. Here's the code I currently have on my first frame of the timeline. When I test the file, I get "TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set htmlText() at textFields_fla::MainTimeline/textFields_fla::frame1()"

      What's wrong?

        • 1. Re: Loading text files info Text Fields on AS3
          Level 7
          when you set the htmlText of myT, that data isn't loaded yet. you should
          add to your loader a listener for when its loaded, and only then set the
          htmlText.

          "RGracia" <webforumsuser@macromedia.com> wrote in message
          news:fasrer$sgq$1@forums.macromedia.com...
          > Hey guys, I am following some examples from Flash CS3 Help files and some
          > portions of the ActionScript 3.0 Cookbook on TextFields. Here's the code I
          > currently have on my first frame of the timeline. When I test the file, I
          > get
          > "TypeError: Error #2007: Parameter text must be non-null. at
          > flash.text::TextField/set htmlText() at
          > textFields_fla::MainTimeline/textFields_fla::frame1()"

          >
          > What's wrong?
          >
          >
          >
          > import flash.display.Sprite;
          > import flash.events.*;
          > import flash.net.*;
          >
          > var source:String = "html.txt";
          > var dataFormat:String = URLLoaderDataFormat.TEXT;
          >
          >
          > var loader:URLLoader = new URLLoader();
          > loader.dataFormat = dataFormat;
          > var request:URLRequest = new URLRequest(source);
          > loader.load(request);
          >
          >
          > var myT:TextField = new TextField();
          > myT.autoSize = TextFieldAutoSize.LEFT;
          > myT.width = 300;
          > myT.wordWrap = true;
          > myT.htmlText = loader.data;
          > addChild(myT);
          >

          • 2. Re: Loading text files info Text Fields on AS3
            RGracia Level 1
            Ahh right, thanks. It works now after listening for COMPLETE: