• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

object problem

Participant ,
Jan 20, 2013 Jan 20, 2013

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

TOPICS
ActionScript

Views

791

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 20, 2013 Jan 20, 2013

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);

...

Votes

Translate

Translate
LEGEND ,
Jan 20, 2013 Jan 20, 2013

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 20, 2013 Jan 20, 2013

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 20, 2013 Jan 20, 2013

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 20, 2013 Jan 20, 2013

Copy link to clipboard

Copied

yeah , this what i want it

thank you mr murphy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 20, 2013 Jan 20, 2013

Copy link to clipboard

Copied

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 20, 2013 Jan 20, 2013

Copy link to clipboard

Copied

LATEST

ohh sorry , just last question

if we do this "new array() ", the limit of array will be ??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines