all groups > flash actionscript > september 2007 >
You're in the

flash actionscript

group:

Newby needs help with external text and actionscript madness.


Newby needs help with external text and actionscript madness. scoots101
9/10/2007 7:54:48 PM
flash actionscript:
Hi,

Trying to load an external plain txt file into a text field using Actionscript
3.0. The text file is saved in UTF-8 format in the same file as the Flash movie
and I'm using the following code:

var external_txt:TextField = new TextField();
var externalReq:URLRequest = new URLRequest("external.txt");
var externalLoad:URLLoader = new URLLoader();

externalLoad.load(externalReq);

externalLoad.addEventListener(Event.COMPLETE, textReady);

external_txt.x = 175;
external_txt.y = 100;
external_txt.border = true;
external_txt.width = 200;
external_txt.height = 200;
external_txt.wordWrap = true;

addChild(external_txt);

function textReady(event:Event):void
{
external_txt.text = event.target.data;
}

When I test the movie, the following error message appears in the output
window:

Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL:
file:///F|/FlashCS3/FlaFiles/external.txt
at ScrollingTextField_fla::MainTimeline/ScrollingTextField_fla::frame1()

I know the solution's probably extremely simple, but I'm new to Actionscript
and can't get round it. Anybody have any suggestions?

Scoots



Re: Newby needs help with external text and actionscript madness. kglad
9/10/2007 8:13:04 PM
Re: Newby needs help with external text and actionscript madness. scoots101
9/10/2007 9:27:34 PM
Thanks for the response kglad,

Re: Newby needs help with external text and actionscript madness. ColemanTO
9/10/2007 9:36:09 PM
Try adding this to the top of the script:

import flash.text.TextField;
Re: Newby needs help with external text and actionscript madness. kglad
9/10/2007 9:54:37 PM
Re: Newby needs help with external text and actionscript madness. scoots101
9/10/2007 10:11:02 PM
Thanks Tom/Kglad,

Tried adding "import flash.text.TextField" but the same thing happens. The text file is in the same directory as the flash document and swf file, so not sure what else it can be?
Re: Newby needs help with external text and actionscript madness. scoots101
9/10/2007 10:39:23 PM
Cheers Kglad,

Checked my folder options and had file type extensions hidden, so had "external.txt.txt" as the URL request. Sorry guys!

Re: Newby needs help with external text and actionscript madness. kglad
9/10/2007 11:32:31 PM
AddThis Social Bookmark Button