We have created a basic example to log in to the SmartFoxServer. Now we are going to create a whiteboard so every connected user can draw on the same whiteboard.
The concept is to add mouse listeners to handle the event when mouse is down, mouse moves, and mouse is up. When the mouse is down and moves, the application broadcasts the mouse coordination to all users within the room and all users then draw the lines according to the received coordination.
We will have a glance of the full code and explain it part by part in detail.
package { import it.gotoandplay.smartfoxserver.SmartFoxClient; import it.gotoandplay.smartfoxserver.SFSEvent; import it.gotoandplay.smartfoxserver.data.Room; import it.gotoandplay.smartfoxserver.data.User; import flash.display.*; import flash.events.MouseEvent; public class Ch03_03 extends MovieClip{ private var _sfs:SmartFoxClient; private var _drawing:Boolean = false; //--------------------------------------- // CONSTRUCTOR...