How Does the Shared Cursor Work?

The Shared Cursor traces your mouse movement using Flash's onMouseMove method. The component copies the x,y values to attributes within a remote SharedObject. When the data is copied, other Flash players are notified and can re-create your mouse and position. This allows you to "track" the mouse activity of connected users. Each user has a slot created within the SharedObject on the server. When data changes within the slot, notifications are sent to each connected client. The notifications are handled by the Flash player by setting the local x,y property to the value of the changed slot (or user). It's a handy tool that uses a simple concept and a great technique for handling data on the server. More will be discussed on the slot concept and the structure of the SharedObject after the next exercise.

The WhiteBoard uses Flash's drawing methods to create arrows and text annotations on the Flash stage. Other Flash players that are connected can see what is happening and add their annotations. Although there is a lot more going on with this application, the basic principle is the same. Each time a line is drawn the WhiteBoard component dynamically creates a new slot within the SharedObject on the server. This is why you can click a line and move it around. This process calls a series of special WhiteBoard methods that draw the new object on other Flash players.

We won't get into reverse engineering the components, but it is important to understand how it all works. In Exercise 8.2, you will use the SharedObject to share MovieClip properties, but first let's look into how the Flash Communication Server synchronizes everything.

    Part I: 10 Quick Steps for Getting Started