RE: [flexcoders] What is the best way to draw about 10,000 to 15,000 rectangles?

2007-02-01 Thread Roger Gonzalez
I had a similar problem drawing dependency graphs.  I've had the best
luck simply drawing them to a Graphics, adding them as children was too
expensive and couldn't keep up with the frame rate.
 
You'll probably want to create a spatial partitioning scheme so that you
can quickly determine mouseover/mousehits.  I did something pretty
simple, just used a coarse version of the coordinates as a hash key to a
list of items in that cell.
 
-rg




From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Gordon Smith
Sent: Thursday, February 01, 2007 4:23 PM
To: flexcoders@yahoogroups.com
    Subject: RE: [flexcoders] What is the best way to draw about
10,000 to 15,000 rectangles?





> adding all of them to the display list takes so long and is
just too much 



What kind of time are you seeing? I was able to add 10,000
UIComponents as children in about 10 seconds. And I was able to add
10,000 Sprites as "raw" children (using rawChildren.addChild()) in about
2 seconds. How fast do you need it to be?



- Gordon







From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of arcencie1978
Sent: Thursday, February 01, 2007 6:50 AM
To: flexcoders@yahoogroups.com
    Subject: [flexcoders] What is the best way to draw about 10,000
to 15,000 rectangles?



Hello folks,

I'm trying to put about 10,000 to 15,000 rectangles 

in a stage.

And I'd like to know what could be the best way to do this..

Of course, I can just draw everything on the stage,

without having to make instances of a class,

which defines the way to draw them.

Yet the thing is that,

every rectangle,sized about 5~10 pixel width and 3 pixel height,

has to respond to events such as mouse over and mouse click
events..

So I've tried to make a cell class and made some 10,000
instances of 
it

but adding all of them to the display list takes so long and is
just 

too much

Yet forgetting about making instances of this sort of class and 
using something like BitmapData 

doesn't give me any idea about how to register events to each
cell..

So is there anybody who has developed this sort of application?

By the way, the reason I have to draw these so many pieces is
because

each cell actually represents a container in the harbor and
there are

just so many of them and my client wants to put all of'em in the

application. 





 



RE: [flexcoders] What is the best way to draw about 10,000 to 15,000 rectangles?

2007-02-01 Thread Gordon Smith
> adding all of them to the display list takes so long and is just too
much 

 

What kind of time are you seeing? I was able to add 10,000 UIComponents
as children in about 10 seconds. And I was able to add 10,000 Sprites as
"raw" children (using rawChildren.addChild()) in about 2 seconds. How
fast do you need it to be?

 

- Gordon

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of arcencie1978
Sent: Thursday, February 01, 2007 6:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] What is the best way to draw about 10,000 to
15,000 rectangles?

 

Hello folks,

I'm trying to put about 10,000 to 15,000 rectangles 

in a stage.

And I'd like to know what could be the best way to do this..

Of course, I can just draw everything on the stage,

without having to make instances of a class,

which defines the way to draw them.

Yet the thing is that,

every rectangle,sized about 5~10 pixel width and 3 pixel height,

has to respond to events such as mouse over and mouse click events..

So I've tried to make a cell class and made some 10,000 instances of 
it

but adding all of them to the display list takes so long and is just 

too much

Yet forgetting about making instances of this sort of class and 
using something like BitmapData 

doesn't give me any idea about how to register events to each cell..

So is there anybody who has developed this sort of application?

By the way, the reason I have to draw these so many pieces is because

each cell actually represents a container in the harbor and there are

just so many of them and my client wants to put all of'em in the

application. 

 



Re: [flexcoders] What is the best way to draw about 10,000 to 15,000 rectangles?

2007-02-01 Thread Daniel Freiman

Assuming the locations are all in some data structure, i'd say keep that
structure and just iterate through each item and draw them on a single
canvas using the Graphics class/object.  Then register a mouse listener for
the entire canvas and calculate which container you clicked on based on the
x and y coordinates of the mouse event.  If the data structure is sorted
this should be a fast enough function.  This solution could have problems
with containers are constantly moving and overlap.  MouseOver graphics
representations could be done by actually putting a new uicomponent over the
container so that you don't have to draw on the canvas as much.  Really this
solution relies on you being able to index and search the data effectively
in any way the application needs.  If I'm not the right direction but
missing something I'll be happy to elaborate on any holes in my idea.

- Dan

On 2/1/07, arcencie1978 <[EMAIL PROTECTED]> wrote:


  Hello folks,

I'm trying to put about 10,000 to 15,000 rectangles

in a stage.

And I'd like to know what could be the best way to do this..

Of course, I can just draw everything on the stage,

without having to make instances of a class,

which defines the way to draw them.

Yet the thing is that,

every rectangle,sized about 5~10 pixel width and 3 pixel height,

has to respond to events such as mouse over and mouse click events..

So I've tried to make a cell class and made some 10,000 instances of
it

but adding all of them to the display list takes so long and is just

too much

Yet forgetting about making instances of this sort of class and
using something like BitmapData

doesn't give me any idea about how to register events to each cell..

So is there anybody who has developed this sort of application?

By the way, the reason I have to draw these so many pieces is because

each cell actually represents a container in the harbor and there are

just so many of them and my client wants to put all of'em in the

application.

 



[flexcoders] What is the best way to draw about 10,000 to 15,000 rectangles?

2007-02-01 Thread arcencie1978
Hello folks,

I'm trying to put about 10,000 to 15,000 rectangles 

in a stage.

And I'd like to know what could be the best way to do this..

Of course, I can just draw everything on the stage,

without having to make instances of a class,

which defines the way to draw them.

Yet the thing is that,

every rectangle,sized about 5~10 pixel width and 3 pixel height,

has to respond to events such as mouse over and mouse click events..

So I've tried to make a cell class and made some 10,000 instances of 
it

but adding all of them to the display list takes so long and is just 

too much


Yet forgetting about making instances of this sort of class and 
using something like BitmapData 

doesn't give me any idea about how to register events to each cell..


So is there anybody who has developed this sort of application?

By the way, the reason I have to draw these so many pieces is because

each cell actually represents a container in the harbor and there are

just so many of them and my client wants to put all of'em in the

application.