Nasim,

As you already know, pre-calculating all those data points is too much work for 
Flash, and it's also way more points than any monitor can show at one time.

Why don't you try calculating only the points you need, only when you need 
them? Tell your boss that 'having an array of points' from -10000 to 10000 is 
the wrong solution.

A solution that will work in Flash is to start by deciding how many points you 
can reasonably plot (for example 1000), then define the 'zoom' of your graph by 
specifying the START and END values, and then plot ONLY 1000 POINTS between 
your start and end values.

Zooming in and out just means changing the START and END values. The onscreen 
display will remain the same size, but the shape of the plotted line will 
change as you zoom in and out.

Also, if you can, you should buy Keith Peter's excellent book "ActionScript 3 
Animation - Making Things Move". It deals specifically with the issues you're 
experiencing.

C:

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim hhhhh
Sent: Tuesday, 23 August 2011 2:13 PM
To: Flash Coders List
Subject: Re: [Flashcoders] array problem,loop.plot

Dear Kerry
Hi
I am really apreciate u , one of my bigest problem is when i want create point 
, my boss want to have an array of point that has distance between -10000 to 
10000 or more than it because when the user want scale graph i should use that 
stoored point to calculate new graph , but the prolem is when i want to store 
data in array this loop take a lot of time and  flash dont do anything until 
the loop finished , and after 15 s it get me eror of time or hang the program 
and close it !!!! 
in my program i should fine soulotion to draw online point plz help me

--- On Mon, 8/22/11, Kerry Thompson <al...@cyberiantiger.biz> wrote:


From: Kerry Thompson <al...@cyberiantiger.biz>
Subject: Re: [Flashcoders] array problem,loop.plot
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Date: Monday, August 22, 2011, 3:34 PM


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 <iranebah...@yahoo.com> 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 <al...@cyberiantiger.biz> wrote:
>
> From: Kerry Thompson <al...@cyberiantiger.biz>
> Subject: Re: [Flashcoders] array problem,loop.plot
> To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
> 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 <iranebah...@yahoo.com> 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
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
This e-mail, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  Any review, 
use, distribution, or disclosure by others is strictly prohibited.  If you are 
not the intended recipient (or authorized to receive information for the 
intended recipient), please contact the sender by reply e-mail and delete all 
copies of this message.

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to