- Topics: Active | Unanswered
Pages: 1
Topic closed
#1 2010-06-06 01:53:31
- **_ksistrunk_**
Trying to use Collaboration builder Sdk to sync mutiple objects
So I have to objects 1 named x_mc and the other named x1_mc
I want that participants can move pieces but with this code I am only seeing the image for x1_mc
What is the problem?
I published this in an actionscript file and used and include statement in my flash move. My flash movie has both movie clips in it. But when I test the movie, I only see the x1_mc But I see it 2 times, and I can move both of them.
Please Help!
Here is the code for the actionscript file. I warn you I am very new to actionscripting.
// First, let's create our initialization object that will be used to create our Square MovieClip
var x_obj:Object=new Object();
x_obj._x=0;
x_obj._y=0;
x_obj.coordArray=new Array(x_obj._x,x_obj._y);
var x2_obj:Object=new Object();
x2_obj._x=0;
x2_obj._y=0;
x2_obj.coordArray=new Array(x2_obj._x,x2_obj._y);
// Template onPress Event Handler for instances
x_obj.onPress=function(){
// we want to start dragging when the participant presses on a square
this.startDrag();
// we will gather some initial co-ordinate information to apply it to the square
x_obj.coordArray[0]=this._x;
x_obj.coordArray[1]=this._y;
// we will pass the event that was triggered by this participant,
// as well as the current co-ordinates.
this.syncThis("onPress",this.coordArray);
}
x2_obj.onPress=function(){
// we want to start dragging when the participant presses on a square
this.startDrag();
// we will gather some initial co-ordinate information to apply it to the square
x2_obj.coordArray[0]=this._x;
x2_obj.coordArray[1]=this._y;
// we will pass the event that was triggered by this participant,
// as well as the current co-ordinates.
this.syncThis("onPress",this.coordArray);
}
// Template onRelease Event Handler for Square instances
x_obj.onRelease=function(){
// trace ("onRelease:");
this.stopDrag();
x_obj.coordArray[0]=this._x;
x_obj.coordArray[1]=this._y;
this.syncThis("onRelease",this.coordArray);
}
x2_obj.onRelease=function(){
// trace ("onRelease:");
this.stopDrag();
x2_obj.coordArray[0]=this._x;
x2_obj.coordArray[1]=this._y;
this.syncThis("onRelease",this.coordArray);
}
// Template syncThis Method for Square instances
// called when onPress or onRelease is triggered.
x_obj.syncThis=function(message,theObj){
// trace out the client firing the event and the nature of the message
trace ("firing syncConnector from "+ syncConnector.userID+" - syncThis: "+message+" " + theObj);
// send the message to other clients. The message consists of a string indicating
// the event triggered, as well as an object storing the information to be processed
// (in this case, an array of co-ordinates
syncConnector.dispatchSyncMessage(message,theObj);
}
x2_obj.syncThis=function(message,theObj){
// trace out the client firing the event and the nature of the message
trace ("firing syncConnector from "+ syncConnector.userID+" - syncThis: "+message+" " + theObj);
// send the message to other clients. The message consists of a string indicating
// the event triggered, as well as an object storing the information to be processed
// (in this case, an array of co-ordinates
syncConnector.dispatchSyncMessage(message,theObj);
}
// Add the caughtUp Event Handler to perform tasks once all messages are received
// could be used to confirm that everything is ok. not really used here.
syncConnector.addEventListener("caughtUp", this);
function caughtUp()
{
// Tasks are performed here to bring the instance of the syncSWF App
// up to speed with the main "host" App
// This event handler is executed
trace ("fn: caughtUp > connection ready");
}
function syncMessageReceived(p_evt){
trace("syncMessageReceived - fired by "+syncConnector.userID);
trace("p_evt.messageValue="+p_evt.messageValue);
switch(p_evt.messageType){
case "onRelease":
trace ("onRelease");
// trace("x_mc="+x_mc);
x_mc._x=p_evt.messageValue[0];
x_mc._y=p_evt.messageValue[1];
break;
case "onPress":
trace ("onPress");
x_mc._x=p_evt.messageValue[0];
x_mc._y=p_evt.messageValue[1];
break;
}
}
syncConnector.addEventListener("syncMessageReceived", this);
this.attachMovie("x2_mc","x2_mc",this.getNextHighestDepth(),x_obj);
trace ("begin");
function syncMessageReceived(p_evt){
trace("syncMessageReceived - fired by "+syncConnector.userID);
trace("p_evt.messageValue="+p_evt.messageValue);
switch(p_evt.messageType){
case "onRelease":
trace ("onRelease");
// trace("x2_mc="+x2_mc);
x2_mc._x=p_evt.messageValue[0];
x2_mc._y=p_evt.messageValue[1];
break;
case "onPress":
trace ("onPress");
x2_mc._x=p_evt.messageValue[0];
x2_mc._y=p_evt.messageValue[1];
break;
}
}
syncConnector.addEventListener("syncMessageReceived", this);
this.attachMovie("x2_mc","x2_mc",this.getNextHighestDepth(),x_obj);
Last edited by **_ksistrunk_** (2010-06-06 01:56:31)
Offline
Pages: 1
Topic closed