Discussion list for Unity developers.
unity-dev at moock.org
Fri Jan 12 14:26:06 CST 2007
Hi Unity developers,
My name is Tony. I just joined this list. Please forgive my
unfamiliarity with Unity.
I'm very new to Unity development (first time). I'm currently working
on a project that is pretty much the uSharedPointer example with the
addition of one thing:
When a user's pointer is clicked on, that particular user gets a visual
cue.
Ex. Users A and B are on the visiting the site. User A clicks on User
B's mouse cursor which in turn causes a visual cue on User B's flash.
I've modified the SharedPointerRoomView class:
public function onNumClients (e:URoomEvent):Void {
client.getTargetMC().numUsers_txt.text = e.getNumClients() + ' (' +
client.getClientID() + ')';
//client.invokeOnClient("onClick", client.getClientID(),
client.getClientID());
trace(e.getNumClients());
}
public function onAddClient (e:URoomEvent):Void {
var clientID:String = e.getClientID();
var username:String;
// Retrieve the remoteuser that represents the client that just
joined.
var remoteuser:RemoteClient =
client.getRemoteClientManager().getClient(clientID);
// Create a Pointer object for the new user.
pointers[clientID] = new Pointer(client.getTargetMC(),
client.getNewTargetDepth());
pointers[clientID].setIcon(Settings.defaultPointerIcon);
var s:String = client.getClientID();
// hide your own pointer
if (clientID == s)
{ pointers[clientID].hide(); }
pointers[clientID].pointerContainer_mc.onRelease = function ()
{
//client.invokeOnClient("onClick", clientID, s);
//var ev:URoomEvent = new URoomEvent(this, clientID, s);
//this.onClick(ev);
//trace(ev.getStatus());
}
var userPositions:Array =
remoteuser.getAttribute(Settings.appNamespaceID
+ "." +
Settings.appRoomID, "posList").split("~");
var userNextPosition:Array = userPositions[0].split(",");
var userX:Number = parseInt(userNextPosition[0]);
var userY:Number = parseInt(userNextPosition[1]);
client.invokeOnClient("setClickerEvent", client.getClientID(),
client.getClientID());
pointers[clientID].moveTo(userX, userY);
}
/**
* URoomListener event handler
*/
public function onClick(e:URoomEvent):Void {
trace(client.getClientID() + ' to ' + e.getStatus());
client.invokeOnClient("onClick", e.getStatus(),
client.getClientID());
}
I've also added this event handler to uSharedPointer class:
public function onClick(e:SocketEvent):Void {
trace(e);
if (getClientID() == e)
{
getTargetMC().showClicker();
}
}
The problem is that the client variable is null when the onRelease event
is triggered. The invokeOnClient() call works in the onNumClients()
event handler. I tried to raise an event but that didn't work, also.
So I'm stuck. Maybe I'm overlooking the obvious.
Please help.
Thank you very much for your time!
~Tony