Sure. I knew there would be bugs in my code :-)
Actually, you have so many points, you probably don't need to use
curveTo(). lineTo() would probably work for you, and it just takes two
parameters.
Here's a class I wrote that draws something. It's probably not what
you want, but it works, at least. You can take it from here. (I
created this class in a Flex AS3 project--that's why I defined the
stage size in line 6. If you do it in Flash, you won't need that--just
set the stage size to what you want).
Cordially,
Kerry Thompson
package
{
import flash.display.Sprite;
import flash.display.Graphics;
[SWF(width='1024',height='768',backgroundColor='#FFFFFF',frameRate='24')]
public class GraphTst extends Sprite
{
private var pointX:Vector.<Number>; //vectors are much faster
than arrays
private var pointY:Vector.<Number>;
private var ndx:int = 0;
private var len:int;
public function GraphTst()
{
init();
createPoints();
drawGraph();
}
private function init():void
{
// You have to create the vector in a new code line
pointX = new Vector.<Number>();
pointY = new Vector.<Number>();
}
private function createPoints():void
{
// first fill the vectors
for (var i:Number= -100; i<100; i++)
{
pointX[ndx]=i + 100;
pointY[ndx]=5*Math.sin(20*i);
ndx++;
}
}
private function drawGraph():void
{
// prepare to draw the graph
graphics.lineStyle(2, 0X000000); //set the line to 2
pixels wide, black
len = pointX.length - 1;
// Now draw the graph
graphics.moveTo(pointX[0], pointY[0]);
for (ndx = 1; ndx< len; ndx++)
{
//trace("ndx: " + ndx);
graphics.lineTo(pointX[ndx], pointY[ndx]);
}
}
}
}
On Mon, Aug 22, 2011 at 2:08 PM, nasim hhhhh <[email protected]> wrote:
> Dear Kerry
> I 'am really appreciate u ,but the first problem that i didnt use curve to is
> it's parameter
> it needs 4 parameter and i cant guess how to define curve point
> do u have any idea plz tell me
>
> --- On Mon, 8/22/11, Kerry Thompson <[email protected]> wrote:
>
> From: Kerry Thompson <[email protected]>
> Subject: Re: [Flashcoders] array problem,loop.plot
> To: "Flash Coders List" <[email protected]>
> Date: Monday, August 22, 2011, 9:41 AM
>
> Gerry and Henrik have the right answer. Your computer monitor isn't
> capable of displaying 20 million points, and Flash will hang, as you
> have found out.
>
> This is untested e-mail AS3, but I would do it something like this:
>
> var pointX:Vector.<Number>; //vectors are much faster than arrays
> var pointY:Vector.<Number>;
>
> // You have to create the vector in a new code line
> pointX = new Vector.<Number>();
> pointY = new Vector.<Number>();
> ndx:int = 0;
> len:int;
>
> // first fill the vectors
> for (var i:Number= -10000 ;i<10000;i+=.1)
> {
> ndx++;
> pointX[ndx]=i;
> pointY[ndx]=5*Math.sin(20*i);
> }
>
> // prepare to draw the graph
> graphics.lineStyle(2, 0X000000); //set the line to 2 pixels wide, black
> graphics.moveTo(pointX[0], pointY[0]); // move to the starting point
> len = pointX.length + 1;
>
> // Now draw the graph
> for (x = 1; x<= len; x++)
> {
> graphics.curveTo(pointX[x], pointY[y];
> }
>
> There's more you have to do--importing the graphics package, perhaps
> putting this all into a class, and so on. There are probably minor
> bugs in the code you'll have to fix--this is just off the top of my
> head. I think you will be much happier with performance and appearance
> with something like this, though.
>
> Cordially,
>
> Kerry Thompson
>
> On Mon, Aug 22, 2011 at 4:49 AM, nasim hhhhh <[email protected]> wrote:
>> but the most problem is for loop i think flash dont do any thing until the
>> loop finishde
>> i need to use smal step because if the step is big the graph will be show
>> like line to line , it s ugly graph
>> and the distance that i use for loop is more importatnt for me i want to
>> show 2*10^8 distance / i want to make point in my program and plot it one by
>> one i make i plot
>> i make i plot
>> is there better way?
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders