
Welcome Guest
|
|
|
#1
|
|||
|
|||
|
Drawing graphs using lineTo function and array vakues
Hi guys and gals,
I have managed to draw a simple graph with the lineTo function pulling in data from an array. The only problem I have is that the line joins the last data point to the first creating a closed shape instead just a 'wiggly' line If anyone can help me solve this I would be eternally grateful Best Steve |
|
#2
|
|||
|
|||
|
Check what you loop over
The error: Don't iterate through all the "n", because you are drawing each line three times, hence the loop. The quick fix: Remove
Code:
for (var n=0; n<myArray.length; n++) { ... } Code:
var n = 0; Code:
// set up an array for different colors for each line
var colorArray:Array = [0x000000, 0xff0000, 0x0033cc];
// iterate through each of the lines
for (var n:Number = 0; n<myArray.length; n++)
{
// create an empty movie clip called "n" for the line at depth n
this.createEmptyMovieClip(n, n);
// set the line style of the line, thickness = 2 and color from colorArray
eval(n).lineStyle(2, colorArray[n]);
// set up the original point of the line
eval(n).moveTo(0, 0);
// iterate through the different points in the line
for (var i = 0; i<myArray[n].length; i++) {
// draw a line that connects to the next point in the line
eval(n).lineTo(i*10, myArray[n][i]);
}
} |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Applying a master function to any array (dynamic targeting syntax) | freaksarise | Flash CS5 |
1 | 04-07-2011 03:36 PM |
| Decompiling haXe | puppy | Members Cafe |
3 | 12-16-2008 10:38 AM |
| Function Consolidation Help | SpectacularStuf | Flash CS3 / Flash 9 |
0 | 09-29-2007 03:20 AM |
| Huh? | Nonsense | Newbies |
2 | 01-06-2007 12:15 AM |
| Help with a Tough Array Randomization/Shuffle Problem | TheMediaBoy | Actionscript 2.0 |
10 | 07-21-2006 09:05 AM |

Programming Languages


