Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

add object in the list

Participant ,
Jan 20, 2013 Jan 20, 2013

hi how are you guys ? i hope you all fine ..

here ...

iam trying to show the list items in the list .. but i couldn.t here

first i created object and array object

var za:int = 0

var itemsinfo:Object = new Object()

var da:Array = new Array (100)

...

then in another place  i set the properties for the object , andi made them arrays objects like this

itemsinfo.name1 = new Array()

   itemsinfo.price1 = new Array()

after that i,ve crated 2 text boxes , one for the item value and the second for the price

additemsvar = additems.text

   addpricevar = int (addprice.text)

then i checked the values in the object

for (var z:String in itemsinfo){

    trace (z + ":" + itemsinfo)

   }

and  every thing is good , but the probelm is when i add these arrays to to the list object, it doesn,t work

i.ve tried with 3 deffrent ways

listbox1.addItem ({label:String(itemsinfo.name1[za])}) //displaying undefined in the list

   listbox1.addItem ({label:(itemsinfo.name1[za])}) //displaying nothing and it just take a place

listbox1.addItem (itemsinfo.name1[za])  // nothing happend

thank you

TOPICS
ActionScript
712
Translate
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

Community Expert , Jan 20, 2013 Jan 20, 2013

itemsinfo.name1 is initialized (to an array) but has no elements so the zero'th element is going to be undefined.

Translate
Community Expert ,
Jan 20, 2013 Jan 20, 2013

itemsinfo.name1 is initialized (to an array) but has no elements so the zero'th element is going to be undefined.

Translate
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

iam not realy sure if i can understand you , but how can i fix it

listbox1.addItem (...)

here is the full code

package {
import flash.display.MovieClip;
   import flash.events.MouseEvent
   import flash.events.Event;

public class MAIN  extends MovieClip {
  var additemsvar:String
  var addpricevar:int
  var removeitemvar:int
  var itemsnp:Array = new Array (100)
  var itemsinfo:Object = new Object()
  var za:int = 0
  var da:Array = new Array (100)
  public function MAIN () {
    addbutton.addEventListener(MouseEvent.CLICK ,addbutton1)
    removebutton.addEventListener(MouseEvent.CLICK ,removebutton1)
    addEventListener(Event.ENTER_FRAME , onEnterFrame)
  addEventListener(Event.ADDED_TO_STAGE,ADDED_TO_STAGE)
  }
  public function ADDED_TO_STAGE (event:Event){
  
   itemsinfo.name1 = new Array()
   itemsinfo.price1 = new Array()
  
  }
  public function onEnterFrame (event:Event){
  
   if(listbox1.selectedIndex != -1){
   itemname11.text = String({label:listbox1.getItemAt(listbox1.selectedIndex)})
   }
  
  
  }
 
 
  public function addbutton1 (event:MouseEvent){
  
   additemsvar = additems.text
   addpricevar = int (addprice.text)
  
   listbox1.addItem ({label:String(itemsinfo.name1[za])})
   listbox2.addItem ({label:itemsnp[za]})
   itemsinfo.name1.push (additemsvar)
   itemsinfo.price1.push (addpricevar)
   za += 1
   trace (itemsinfo.name1)
   for (var z:String in itemsinfo){
    trace (z + ":" + itemsinfo)
   }
  
   }
  public function removebutton1 (event:MouseEvent){
  
   trace (listbox1.selectedIndex)
  
   listbox1.removeItemAt(listbox1.selectedIndex)
  
  }
  function traceItemsnpF(a:Array):void{

for(var i:int=0;i<a.length;i++){

for(var s:String in a){

trace(s,a+":"+a);

}

}

}

 
}
}

thank you for the replay

Translate
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

nvm . i.ve fixed it

thank you a lot mr kglad for your help .

Translate
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
Community Expert ,
Jan 20, 2013 Jan 20, 2013
LATEST

you're welcome.

Translate
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