HI Nasim, You can save that many numbers in an array. We're talking about 20,000 numbers, and Flash can handle that in an array or a vector.
Yes, you can use one vector and store points in it. As to re-initializing the Vector, I like to use vect = new Vector(). I think setting the length to 0 will work, though--it's easy enough to test. I think you can even reset it by setting vect[0] = null; Computing the points is pretty fast. Its the drawing that is slow. I'm going to disagree with Henrik, though. Unless the points are going to change at some point, I would calculate once and keep it. You can even draw once, into a sprite, and keep it. I would put it in a data object, or even a class with public static vars. If you draw it once, and have it in a sprite you can put on stage, then it's just a matter of scaling it. If you're going to zoom in a lot, I would definitely use lineTo() or curveTo(). Otherwise it will pixellate when you zoom in close. Bear in mind that you are going to have x values of -10,000, so you'll need to compensate when you put it on the stage. Still, it is a doable task. Cordially, Kerry Thompson On Tue, Aug 23, 2011 at 6:07 AM, nasim hhhhh <iranebah...@yahoo.com> wrote: > Hi kerry > I think there should be morning so good morning > i think i should convince my boss that i cant save that number of point in > aray > u know ifirstly i wanted to make point and save it and i just draw that point > what are visible in page to use them in diferent situaion of user activity , > my gaph has scale + and - > i draw visiblle point with scale factor again we need that points to simulate > pulse train , and have scale until 10^5 or more > by the way > about using vector as array is it better to use vector of point type or use 2 > vector of number type??? > is it ok to clear vector by this code vect.length=0 > best regard > nasim > > --- On Tue, 8/23/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: Tuesday, August 23, 2011, 12:35 AM > > > Hi Nasim, > > You can certainly create an array of 20,000 elements (or two Vectors, > as I did, with a smaller number). > > The problem is, I don't think you can display that many points. How > big is your stage? I had mine set to 1024 x 768, which is normally > about as high as you want to go. > > You don't need that many points to create a smooth graph, though. Try > using every 10th point, and either lineTo or curveTo. > > To do that, in the part that creates the graph, increment by 10: > > // Now draw the graph > for (x = 1; x<= len; x+=10) > > Did you get my second e-mail, where I wrote the class for you? It uses > lineTo(), which should give you pretty smooth graph with 2,000 points. > My class isn't bug-free, but it is free, and you should be able to > make it do what you want. If not, I'll take another look at it in the > morning (it's after midnight here). > > Cordially, > > Kerry Thompson > > > On Tue, Aug 23, 2011 at 12:13 AM, nasim hhhhh <iranebah...@yahoo.com> wrote: >> 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 >> > > _______________________________________________ > 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