Last night, I Googled a lot and couldn't find the solution for my problem:
I have a for loop with one function in it which gets me only the latest value from the array.
So, here is the example:
obj1.route = new Routeng();
obj2.route = new Routeng();
for(var x in arrObjs) { //arrObjs = array of objects
var g = arrObjs[x];
// I can access properties of all "g" objects
Routelousse.gen(function(res) {
var pathern = res.pathern;
g.routel.staviPather(pathern);
MYOBJ.vehicles.push(g);
alert(g.name); // during the loop I always get the LAST "g" object from "arrObjs"
}, g.point);
}
gis re-used everyforloop pass, so the incorrect one is being used when that asynchronous function completes.