# Dynamic text input from generated text file

**URL:** https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929
**Category:** flash
**Created:** [May 10, 2008, 10:30am UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929 "2008-05-10T10:30:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![SQuRIlLe](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SQuRIlLe](https://forum.kirupa.com/u/SQuRIlLe)
#### Post date: [May 10, 2008, 10:30am UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929/1 "2008-05-10T10:30:39Z")

</div>

Hello all,  
I’m currently doing work for a local cinema that wants session times to be displayed as .swf’s on a few monitors in the foyer, but I’m having difficulties writing the script for it, here’s the situation:

The session times are generated daily as a text file by the ticketing software, it looks like this:

12 1 0950 101 0 330 0 M MADE OF HONOUR  
1 1 1000 95 0 400 0 M WHAT HAPPENS IN  
6 1 1000 95 0 154 0 M SMART PEOPLE  
9 1 1010 92 0 300 0 PG MISS PETTIGREW  
5 1 1015 126 0 408 0 M IRON MAN  
3 1 1020 92 0 347 0 M SMOTHER  
14 1 1030 101 0 38 0 M MADE OF HONOUR  
11 1 1035 111 0 186 0 MA15+ FORGETTING SARAH  
8 1 1050 108 0 276 0 MA15+ STREET KINGS  
10 1 1055 123 0 160 0 M PAINTED VEIL  
4 1 1100 95 0 833 0 M WHAT HAPPENS IN  
15 1 1100 126 0 42 0 M IRON MAN  
7 1 1115 108 0 209 0 MA15+ DECEPTION  
2 1 1145 126 0 441 0 M IRON MAN  
12 2 1200 101 0 330 0 M MADE OF HONOUR  
13 1 1200 95 0 56 0 M WHAT HAPPENS IN  
6 2 1205 100 0 154 0 MA15+ UNTRACEABLE  
1 2 1210 95 0 400 0 M WHAT HAPPENS IN  
etc…

What I’m trying to generate in the .swf is something that looks like this

Made of Honour (M) 9:50 10:30 12:00  
What Happens in (M) 10:00 11:00 12:00 12:10  
etc…

Additional requirements are the times disappearing after the session has started as well as session times 13-16 being displayed as a separate .swf (first class seating)

So i guess my main question is “can i dynamically load text from a multi-line txt file without editing the txt file to include variable assignment? (‘content=’ etc)”

- the txt file generated is intended for an led display and is apparently a Texas Instruments standard

---

<div class="post-metadata">

### Author: ![souled](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@souled](https://forum.kirupa.com/u/souled)
#### Post date: [May 10, 2008, 8:20pm UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929/2 "2008-05-10T20:20:06Z")

</div>

Well say you have one of those lines as  
\*\*  
var text\_file:String = “12 1 0950 101 0 330 0 M MADE OF HONOUR”;\*\*

then you can make an array holding all the values splitting it at the space  
\*\*  
var text\_array:Array = new Array();  
text\_array = text\_file.split(" ");\*\*

So if you trace the array you’ll have them all separated into the sections of the array. So if we

**trace(text\_array);**

then we’ll get the whole array, but if we

**trace(text\_array[0]);**

then we get just 12. Hopefully you can carry on from there. 🙂

---

<div class="post-metadata">

### Author: ![SQuRIlLe](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SQuRIlLe](https://forum.kirupa.com/u/SQuRIlLe)
#### Post date: [May 12, 2008, 1:01am UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929/3 "2008-05-12T01:01:48Z")

</div>

that’s awesome thanks! i’ll keep working on it today and post back the result. lifesaver!  
sq

---

<div class="post-metadata">

### Author: ![SQuRIlLe](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SQuRIlLe](https://forum.kirupa.com/u/SQuRIlLe)
#### Post date: [May 12, 2008, 5:20am UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929/4 "2008-05-12T05:20:20Z")

</div>

[LEFT][COLOR=#993300]cool, how do i pull the info from a txt file rather than the string?  
i can load the text as is like this:

var[/COLOR] loader:URLLoader = [COLOR=#993300]new[/COLOR] URLLoaderCOLOR=#000000[/COLOR];  
[COLOR=#993300]var[/COLOR] theMovies:[COLOR=#993300]Array[/COLOR] = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Array[/COLOR]COLOR=#000000[/COLOR];

loader.[COLOR=#993300]load[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]new[/COLOR] URLRequestCOLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];  
loader.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]COMPLETE[/COLOR], loadComplete[COLOR=#000000])[/COLOR];

[COLOR=#993300]function[/COLOR] loadCompleteCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]  
theMovies = event.[COLOR=#993300]target[/COLOR].[COLOR=#993300]data[/COLOR].[COLOR=#993300]split[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"[COLOR=#000099] **\r** [/COLOR][COLOR=#000099]\*\*  
\*\*[/COLOR]"[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#993300]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]var[/COLOR] i:[COLOR=#993300]int[/COLOR] = [COLOR=#000000]0[/COLOR]; i \< theMovies.[COLOR=#993300]length[/COLOR]; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}

but i’m confused as to how to do this  
the txt file will get replaced everyday automatically so i can’t have any strings that are unique to a particular txt file, i need to be able to drop any text file in with it and have it open the text file and gather info that way…  
well this is ■■■■ tricky.  
cam  
[/COLOR]  
[/LEFT]

---

<div class="post-metadata">

### Author: ![souled](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@souled](https://forum.kirupa.com/u/souled)
#### Post date: [May 12, 2008, 4:40pm UTC](https://forum.kirupa.com/t/dynamic-text-input-from-generated-text-file/259929/5 "2008-05-12T16:40:32Z")

</div>

Is that AS3? I only know AS2. And I don’t see how a text file and a string should have any difference… Also I don’t have much experience in loading stuff from text files, sorry. 😕
