2

i would like to update the numbers i've added to an array from variables, when those variables change. is it possible change these variables and have the array update automatically?

var first:Number = 1;
var second:Number = 2;

var myArray:Array = new Array(first, second);

first = 3;
second = 4;

trace(myArray) //outputs 1,2

1 Answer 1

3

Instead of storing a primitive type ( Number ), use an Object to wrap Number. Something like this pseudo-code:

var first:Object = { value: 1 };
var second:Object = { value: 2 };

var array:Array = [ first, second ];

first.value = 3;
second.value = 4;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.