Skip to main content
Inspiring
July 21, 2006
Answered

dynammically creating MC's for lineto

Hi all. I've read in some data from an xml file that contains various x and y coordinates. I need to now draw lines between them all. I understand how to draw A line ie:

_root.createEmptyMovieClip("triangle_mc", 1);
triangle_mc.moveTo(182, 508);
triangle_mc.lineStyle(1, 0xFF00FF, 100);
triangle_mc.lineTo(values[xaxis], values[ i ]);

Which works just fine. The problem is, I do not know how many lines I will need. I tried doing some sort of naming standard such as this:

temp = "lineName"+count
_root.createEmptyMovieClip(temp, 1)
count++
temp.moveTo(182, 508);
temp.lineStyle(1, 0xFF00FF, 100);
temp.lineTo(values[xaxis], values[ i ]);

but to no avail. Perhaps I am missing something obvious here. Could anyone point me in the right direction or perhaps a better way to do this? Thanks in advance!
This topic is closed to new replies. Start a new post to keep the conversation going.
micahkogaCorrect answer
Participating Frequently
July 21, 2006
Here's a way

6 replies

Participating Frequently
July 21, 2006
Is there some way you can get the length from the xml data? Maybe create a counter when you're loading in the data? Please elaborate
Translate
July 21, 2006
Load all of the data into an array and the index through them one at at time until your index greater than or equal to the array length.
Translate
Inspiring
July 21, 2006
quote:

Originally posted by: Jim Esteban
Load all of the data into an array and the index through them one at at time until your index greater than or equal to the array length.


I think I am missing something obvious here. I have the lengths. The xml data may change but I will always have a variable with the length. Problem is, how can I create enough empty movie clips to draw the lines without hard coding in each name...if that makes sense.
Translate
micahkogaCorrect answer
Participating Frequently
July 21, 2006
Here's a way
Translate