Ask a Question related to Macromedia Flash Flashcom, Design and Development.
-
NormC_CAE #1
Convert Shared Object properties into ordered array
I need to put the shared object data (that contains the client names) into an
ordered array.
The following is NOT useful:
for (var i in _chatSO.data) {
if (_chatSO.data[i] != null) {
var clientObj = _chatSO.data[i];
users.push(clientObj.username);
}
}
That doesn't solve my problem because each client will end up with an array of
different order, e.g., [client1, client2, client3] and [client2, client1,
client3] etc.
Context: Multiplayer game where I make 2 teams and assign a number and colour
(color) to each player. Each client (player) that joins needs to create movie
clips representing the previously joined players, each labeled with a number.
Unless they have access to the same array, it can't be done.
Thank you,
Norm (new to FMS)
NormC_CAE Guest
-
Saving an Array to a Shared Object
Hi Folks (1) - Assuming I create an array as follows; row1=new Array("One" , "Two" , "Three"); row2=new Array("Four" , "Five" , "Six");... -
remote shared object array
Hi I'm haveing trouble with creating a array on the server side so far i have this code but i keep getting the error message this.myRSO has no... -
Shared user object array
Maybe I am miss understanding this, but I have taken the sample_textchat application and have modified it slightly for my usage, I have got; ... -
Convert object attributs into indexed array
Hi all, I would like to know if it is possible de dynamically convert all attributs from an object into 2 indexed arrays, one for the attribut... -
array elements matching object properties ?
I'm trying to sort out an application where I need create a conditional statement that matches elements of an array and properties of several... -
B_Shack #2
Re: Convert Shared Object properties into ordered array
Norm,
Here is the process for pushing so data into an array...
Shack
// Object iterator
function iterateObject(obj:Object):Void
{
if(obj != undefined){
for(var prop in myObject){
trace("Property :" + prop + "\tValeu :" + myObject(prop));
}
} else {
trace("Object required");
}
}
function reverseObject(obj:Object):Void
{
var a = [];
for ( var p in obj )
{
a.push ( { key: p, value: obj[p] } ); }
var len = a.length;
for ( var i = 0; i < len; i++ )
{
var item = a[i];
var key = item.key;
var value = item.value;
}
}
/*
Shared Object Info
You can store objects, or arrays of objects in a shared object property. The
server side code would look something like this:
my_so = SharedObject.get("someSharedObject", false);
myObject = new Object();
myObject["childObject1"] = new Object();
myObject["childObject2"] = new Object();
my_so.setProperty("somePropertyName", myObject);
So, now you have a property in the shared object named somePropertyName, and
its value is and object with two child objects. If you then wanted to
manipulate the object, you would do something like this:
myObject = my_so.getProperty("somePropertyName");
var someVar="someValue";
myObject.childObject1["somevar"] = someVar;
my_so.setProperty("somePropertyName", myObject);
What we did here was read the value of the shared object property into a
variable, add a variable to one of the child objects, and write the parent
object back into the shared object property.
A shared object can have as many properties as you need (a shared object is
still an object after all), you you can use separate properties to manage
separate arrays or arrays of objects.
*/
B_Shack Guest



Reply With Quote

