Forum BigDB need help with client.bigDB.loadRange

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

need help with client.bigDB.loadRange

Postby wbsaputra » September 30th, 2010, 7:54 pm

why i can't pass BigDb array load result to other var array??
I had trace out z array and nothing,but if i trace inside load function is work.
I need to push load BigDB array result to private class variable.
Thanks for any help

here's my code
Code: Select all
private var z:Array = [];

client.bigDB.loadRange("MyObjects", "ByType", null, "01", "03", 20,
  function(MyData:Array):void{
    for( var a:int=0;a<MyData.length;a++){
      var x:Object = MyData[a];                  
        var y:Object = {                     
        Type   :x.Type,
        Status:x.Status,
        Level   :x.Level
      }
      trace(y); //trace is working here
      z.push(y);
    }
  }
);                  

trace(z); //not working here
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: need help with client.bigDB.loadRange

Postby default0 » September 30th, 2010, 9:44 pm

wbsaputra wrote:why i can't pass BigDb array load result to other var array??
I had trace out z array and nothing,but if i trace inside load function is work.
I need to push load BigDB array result to private class variable.
Thanks for any help

here's my code
Code: Select all
private var z:Array = [];

client.bigDB.loadRange("MyObjects", "ByType", null, "01", "03", 20,
  function(MyData:Array):void{
    for( var a:int=0;a<MyData.length;a++){
      var x:Object = MyData[a];                  
        var y:Object = {                     
        Type   :x.Type,
        Status:x.Status,
        Level   :x.Level
      }
      trace(y); //trace is working here
      z.push(y);
    }
  }
);                  

trace(z); //not working here


The array variable, z, is probably being garbage collected, try declaring it inside the callback of loadRange (or try tracing z inside the callback to check if z really is null as I believe it to be), or, if you need to access z later just declare it as you declare your class.

I hope this helps

Best regards
Try to play my Game: -->BlackGalaxy<--
User avatar
default0
 
Posts: 115
Joined: February 2nd, 2010, 6:46 pm
Location: Germany

Re: need help with client.bigDB.loadRange

Postby wbsaputra » October 1st, 2010, 1:38 am

thanks for reply,
yes i'm declaring z as class variable, i need to put bigdb data in here, i want it used in other function inside this class, but z always null.
But if i'm tracing z in loadrange function is working. do i always have to proses bigdb data inside load function?
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm


Return to BigDB



cron