all groups > macromedia flash flashcom > september 2006 >
You're in the

macromedia flash flashcom

group:

Creating bitmaps



Creating bitmaps telarium
9/19/2006 7:37:47 PM
macromedia flash flashcom: Thinking of doing a multiuser white board application. The idea is that there
are many rooms where 15 to 30 users can simultaneously paint on a canvas over
the course of three hours.

The problem I'm having is this: If each painting session lasts for three
hours, and if someone were to join two and a half hours into the session, I'm
going to need to send them all the canvas information up to that point.
However, I'm thinking I can't do this as just objects or arrays of data. By my
calculation, this could be megs and megs of data towards the end of the three
hours.

Is there any way for the Flash Media Server to somehow create bitmap snapshots
of the canvas at certain intervals and send that to users who join late in the
process? Or am I thinking about this in the wrong way?
Re: Creating bitmaps JayCharles
9/19/2006 8:06:29 PM
No... FMS cannot save a bitmap for you.

Actually, you are looking at this the wrong way. For a whiteboard, what you
want to do is send drawing data to the clients, and let the client (the flash
movie) do the actual drawing using Flash's drawing classes.

There is a whiteboard component in the Communication Components. It's written
in AS1, so you can look at the code of the component (and the accompanying
whiteboard.asc in the FMS scriptlib. This will show you how the data is saved
to a shared object without creating data for each pixel on the whiteboard.
Re: Creating bitmaps telarium
9/19/2006 8:14:16 PM
Yes, that was what I originally had in mind as well. However, like i said, the
idea is that this could be 30 people in one room drawing over the course of 3
hours. Even if you capture just simple drawing data, it really starts to add up
after a while and can spin out of control.
Re: Creating bitmaps JayCharles
9/20/2006 12:35:02 AM
I suppose it depends on how cluttered the whiteboard stage gets... and how
efficient your data structure is.

For example, let's say someone draws a square. The data you might need is
width, height, fill color, line color, line weight, x, y, and z. All in all,
that's just a few bytes. Even if you have a thousand rectangles on the stage,
it's still not all much data.
Re: Creating bitmaps telarium
9/20/2006 3:27:03 PM
It?s true that it?s only a few bytes of data, and bandwidth is not much of a
concern to me any longer on this. However, let?s consider a possible (although
unlikely) scenario where all 30 people in the room have been drawing a
rectangle every second for three hours. If I were to send all the data in a
multidimensional array, in the end, you could have an array 324,000 items long.
Imagine having to go through a for loop in the Flash player and draw all of
that data on the stage. It would grind any computer to a halt? until AS3, I
suppose. :) It?s true that you could break this array up into smaller parts and
draw the canvas over multiple frames, but to run decently, that might still
take something like 40 seconds initially.
Re: Creating bitmaps JayCharles
9/20/2006 4:48:47 PM
Well... I suppose you could set things up so that when an object is completely
covered by other objects, it is removed from the list (might be easiest to do
that on the client side). Of course, that wouldn't work if users are able to
move or delete inidvidual objects.

Going back to your bitmap idea, I suppose you could make it a sloppy client
side event. If you're checking bandwidth when you clients connect, you could
pick the client with the best connection speed, have that client's .swf create
a bitmap object of the drawing stage, and send the data to an http application
server (php, asp, etc). The application server could then compile the bitmap
and save it. Keep in mind that this sort of thing can put a lot of load on the
http server if the bitmap is large (we're sending/compiling the data pixel by
pixel), and if your client disconnects, there would be problems.

Another option might be a .swf that runs on the server, connects to the FMS
app, and sends the bitmap data.
AddThis Social Bookmark Button