Forum BigDB Naming objects

Discussion and help relating to the PlayerIO database solution, BigDB.

Naming objects

Postby HarryK » November 12th, 2010, 9:15 pm

How would i go about naming a object after a variable string or number value?
I want 20 objects created in a for loop but cant use the variable to name the object.

Code: Select all
client.bigDB.loadMyPlayerObject(function(obj:DatabaseObject):void{
            for(var i=0;i<=20;i++) {
               obj.part[i] = {1:"0", 2:"0", 3:"0", 4:"0"};
            }
            obj.save();
         });


Thanks
HarryK
 
Posts: 2
Joined: October 21st, 2010, 11:50 pm

Re: Naming objects

Postby Benjaminsen » November 14th, 2010, 3:18 pm

To do what you want, part must be an array or object.

ie

Code: Select all
client.bigDB.loadMyPlayerObject(function(obj:DatabaseObject):void{
            obj.part = obj.part || []
            for(var i=0;i<=20;i++) {
               obj.part[i] = {1:"0", 2:"0", 3:"0", 4:"0"};
            }
            obj.save();
});
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to BigDB