Convert Shared Object properties into ordered array

Ask a Question related to Macromedia Flash Flashcom, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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");...
    2. 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...
    3. 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; ...
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139