PDA

View Full Version : Multiple shared balls Help?


crazydev
11-23-2007, 11:15 AM
Hey guys!
I want to make an application like sharedball. But i want to make multiple shared balls onto the stage. I'm not much experienced with FMS. Please anyone give me some idea or some example regarding how i can handle multiple balls simultaneously. Thanks in advance.

mr-webcam
11-25-2007, 07:40 PM
this application is very basic but is based on the flashcom shared ball demo,
http://www.mr-webcam.co.uk/flashcom/crazy-letters-plus/index.php
You need to create a SO for each ball like this :-

// Create a remote shared object
//change to false if you do not wish positions to be saved when app is closed
t1_so = SharedObject.getRemote("position", client_nc.uri, true);

// Update ball position when another participant moves the ball
t1_so.onSync = function(list) {
t1_mc._x = t1_so.data.x;
t1_mc._y = t1_so.data.y;
};

// Connect to the shared object
t1_so.connect(client_nc);

// Manipulate the ball
t1_mc.onPress = function() {
this.onMouseMove = function() {
t1_so.data.x = this._x = _root._xmouse;
t1_so.data.y = this._y = _root._ymouse;

// Constrain the ball to the stage
if (t1_mc._x>=Stage.width) {
t1_mc._x = Stage.width - 50;
}
if (t1_mc._x<=0) {
t1_mc._x = 50;
}
if (t1_mc._y>=Stage.height) {
t1_mc._y = Stage.height - 50;
}
if (t1_mc._y<=0) {
t1_mc._y = 50;
}
};
};

// Release control of the ball
t1_mc.onRelease = t1_mc.onReleaseOutside=function () {
delete this.onMouseMove;
};