- Home /
Help with transfering values from one array to another
Defenition of products array in Script 1 (exportScript)
var products = new ExportInventory[3];
Defenition of goodsList in Script 2 (G)
static var goodsList = new Dictionary.<int,Goods>();
Script 3, where the problem is
var i : int = 0;
for(p in G.goodsList.Values){
exportScript.products[i].goodId = p.goodId;
i++;
}
Can anyone tell me why all exportScript.products[i].goodId entries gets set to the last value in the G.goodsList.Values p.goodId is different on each step in the loop as it should.
hmm exportScript.products is only declared, nothing else is done to it...
Can you show me the declaration? (Warning: I'm not experienced in java script). But that code segment looks sane and correct so I'm pretty sure the problem lies in what that content of exportSctipt.products is.
Turn out I had made the class ExportInventory static. Thanks @larku for sending me in the right direction. That was fun hours :blush:
Convert to answer and Ill close the question.
Answer by larku · Jun 23, 2013 at 02:45 PM
How have you populated exportScript.products? Is it possible that all of the exportScrip.products[?] objects refer to the same object? hence each time you're setting goodId you're setting it on the same object over and over?
Your answer
Follow this Question
Related Questions
Array Index is Out Of Range... 0 Answers
how to save and load the game state 1 Answer
How to set distance? 1 Answer
GetComponent from class 1 Answer
JS Array Object to Float 1 Answer