# Question about lineTo . . . from a text file?

**URL:** https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636
**Category:** Uncategorized
**Created:** [November 4, 2003, 8:15pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636 "2003-11-04T20:15:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)
#### Post date: [November 4, 2003, 8:15pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/1 "2003-11-04T20:15:29Z")

</div>

I have a question about lineTo.

Let’s say I wanted to dynamically draw a cityscape - just a bunch of straight lines and right angles. But there are lots of x,y coordinates to make the whole thing. Would it possible to put all those coordinates in a text file and then call that from Flash? As in, lineTo(use line 1 of text file, then use line 2, then use line 3) etc.

Is this possible? And if so, what sort of AS is used? And does the text file have to be in a certain formate? (like x,y one per line or on one line separated by parentheses, or . . . ?).

Thanks for any help!:}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 4, 2003, 8:41pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/2 "2003-11-04T20:41:27Z")

</div>

```auto

var lineLoad = new LoadVars();
lineLoad.load("example.txt");
lineLoad.onLoad = function(){
	_root.createEmptyMovieClip("holderClip",100);
	coords = this.coords;
	coords = coords.split("|");
	for(var i = 0;i<coords.length;i++){
		coords* = coords*.split(",");
	}
	_root.holderClip.lineStyle(1,0x000000, 100);
	for(var i = 0;i<coords.length;i++){
		_root.holderClip.lineTo(coords*[0], coords*[1]);
	}
}

```

and the values of the text file:  
&coords=20,30|40,50|10,12|430,21

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 4, 2003, 9:03pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/3 "2003-11-04T21:03:26Z")

</div>

Hey thanks! I’ll give it a shot.

😃

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 6, 2003, 6:02am UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/4 "2003-11-06T06:02:19Z")

</div>

Didn’t work . . . :h:

I’m not sure I’m accessing the text file. Here is what I have:

```auto

var lineLoad = new LoadVars();
lineLoad.load("numbers.txt");
lineLoad.onLoad = function(){
        _root.createEmptyMovieClip("holderClip",1);
        coords = this.coords;
        coords = coords.split("|");
        for(var i = 0;i<coords.length;i++){
                coords* = coords*.split(",");
        }
        _root.holderClip.lineStyle(2,0x000000, 100);
        for(var i = 0;i<coords.length;i++){
                _root.holderClip.lineTo(coords*[0], coords*[1]);
        }
}

```

and when I test the movie it’s just blank.

Any suggestions?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 6, 2003, 7:45am UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/5 "2003-11-06T07:45:28Z")

</div>

Here are my files:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 12:58am UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/6 "2003-11-07T00:58:55Z")

</div>

Hey NJS - I couldn’t open your fla ☹ I got an “unexpected file format”.

Also, is there any way to use the text file without using the “|”? I have a LOT of coords.

And finally, do the numbers have to be rounded? Can I use tenths?

Thanks for your help!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 6:42pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/7 "2003-11-07T18:42:56Z")

</div>

well, the way it all works is that it uses a logical separator(in this case |) to separate the coordinates, so it would be quite difficult to think of a way without using some separator. You can use a different one though, just replace the | with the other character :). I think you should be able to use tenths.

And you’re welcome - I’d done something very similar to this before so it was only a case of modifying it slightly.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 7:47pm UTC](https://forum.kirupa.com/t/question-about-lineto-from-a-text-file/34636/8 "2003-11-07T19:47:37Z")

</div>

Hey that works great! Thanks! Sorry I forgot to mention I was using MX 😊

Question - how can I get it to draw more slowly? Even if I change the frame rate to 0.1 it sort of just appears. I would like the shape to draw itself as the viewer watches. Is it possible to set a drawing rate in AS?

Thanks again!:s:
