Be a Supporter!

How can I import a .txt into Flash?

  • 164 Views
  • 4 Replies
New Topic Respond to this Topic
Mufanza
Mufanza
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
How can I import a .txt into Flash? 2010-12-18 08:59:54 Reply

Hi, here's the thing: I will have a lot of big arrays and stuff in my game, but keeping them all in a frame code would be unpractical because of how big they will be.
So I was thinking: can't I just write them into a .txt file, and then use flash to load them from there?
But when I try to import .txt into a library, it has problem reading it.

Does anyone know how can I solve this?

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to How can I import a .txt into Flash? 2010-12-18 09:13:26 Reply

You can use '#include' or 'include' in AS3 to include a piece of script verbatim. Or you can just use a class file to define data in.


BBS Signature
CyberXR
CyberXR
  • Member since: Aug. 22, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to How can I import a .txt into Flash? 2010-12-18 09:14:04 Reply

Hello!
I don't know which language you use but you could always try:
f.open("nameoffile.txt", "r");
list = f.read()
f.close()

At 12/18/10 08:59 AM, Mufanza wrote: Hi, here's the thing: I will have a lot of big arrays and stuff in my game, but keeping them all in a frame code would be unpractical because of how big they will be.
So I was thinking: can't I just write them into a .txt file, and then use flash to load them from there?
But when I try to import .txt into a library, it has problem reading it.

Does anyone know how can I solve this?

Check out the coolest Donkey Kong Game on NG!
http://www.newgrounds.com/portal/vi ew/459064
100 posts @ Posted at: 9/15/08 07:36 AM http://www.newgrounds.com/bbs/topic /969232

Jin
Jin
  • Member since: Sep. 9, 2006
  • Offline.
Forum Stats
Supporter
Level 50
Blank Slate
Response to How can I import a .txt into Flash? 2010-12-18 09:17:34 Reply

URLLoader. By doing that, you must host your text file if you want to put your flash on the web.


BBS Signature
Mufanza
Mufanza
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to How can I import a .txt into Flash? 2010-12-18 12:44:37 Reply

At 12/18/10 09:13 AM, GustTheASGuy wrote: You can use '#include' or 'include' in AS3 to include a piece of script verbatim. Or you can just use a class file to define data in.

That'll do, thanks man!