Copy link to clipboard
Copied
hi how are you guys ? i hope you all fine ..
here ..
iam having problem with object , i want to make the object properties arrays ..
am gonna explain the code that will be better
first i want to create object
a:Object = new Object()
a.itemname = itemnamevar
a.itemprice = itempricevar
this the object and the itemnamevar and the itempricevar are also object (2 text boxes) so the variables contents
itemnamevar = item.text
itempricevar = int(price.text)
so when i enter the name and the price for the customers it will be only one place
and it is going to change every time
for ( i:string in a){
...
trace() // here they gonna change every time , i mean after entring another price and name
}
so .. i need to put these in array , but i realy dont know how to this in object class
thank you
The array will contain each object you create. In having that, you will have every property of each object accssible vi the object in the array.
If I missed your intentions, which is quite possible, and your quest for an array is to have arrays for the properties, meaning you have only one Object but it should have arrays of the same properties, then you would want to use something like...
var a:Object = new Object();
a.itemname = new Array();
a.itemprice = new Array();
a.itemname.push(itemnamevar);
...Copy link to clipboard
Copied
It is not clear to me what you are trying to do but if you think you need an array then just create an array the same way you went about creating the object.
var objects:Array = new Array();
var a:Object = new Object();
a.itemname = itemnamevar
a.itemprice = itempricevar
objects.push(a);
That ends up giving you an array of objects, currently holding just the one Object "a". If that is not what you intend, please explain further what is different about what you want.
Copy link to clipboard
Copied
is he now going to push all the properties in the array??
i mean this "objects.push(a);" a.itemname and a.itemprice will be in the objects array?
like when we trace objects like this (objects[0]) we will get them , the price and the name
thank you for your replay
Copy link to clipboard
Copied
The array will contain each object you create. In having that, you will have every property of each object accssible vi the object in the array.
If I missed your intentions, which is quite possible, and your quest for an array is to have arrays for the properties, meaning you have only one Object but it should have arrays of the same properties, then you would want to use something like...
var a:Object = new Object();
a.itemname = new Array();
a.itemprice = new Array();
a.itemname.push(itemnamevar);
a.itemprice.push(itempricevar)
Copy link to clipboard
Copied
yeah , this what i want it
thank you mr murphy
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
ohh sorry , just last question
if we do this "new array() ", the limit of array will be ??