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

list problem

Participant ,
Jan 21, 2013 Jan 21, 2013

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

here ...

iam trying to make text box as miror for the list object

am gonna explain with images

here

there is 2 frames

first frame

i can enter the name and the price for the item

103-213.png

and when i do that(clicking add item), the item is going to the list object (in the second frame)

108-189.png

but the problem now , is when i try to make a miror for the list in text box it doesn,t work 

105-767.png

i.ve tried to make it string

  

helper = listbox1.selectedIndex

itemname11.text = String(listbox1.getItemAt(helper))

but still displaying it as object

...

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)
  var helper:int
  var helper1:String
  var helper2:String
  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){
   helper = listbox1.selectedIndex
   if(listbox1.selectedIndex != -1){
   itemname11.text = String(listbox1.getItemAt(helper))
   }
  
  
  }
 
 
  public function addbutton1 (event:MouseEvent){
  
   additemsvar = additems.text
   addpricevar = int (addprice.text)
  
   listbox2.addItem ({label:itemsnp[za]})
   itemsinfo.name1.push (additemsvar)
   itemsinfo.price1.push (addpricevar)
   listbox1.addItem ({label:(itemsinfo.name1[za])})
   za += 1
  
   for (var zb:String in itemsinfo){
    trace (zb + ":" + itemsinfo[zb])
   
   }
  
   }
  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

TOPICS
ActionScript
1.6K
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

Guru , Jan 21, 2013 Jan 21, 2013

but still displaying it as object

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/SelectableList.html#getItemAt%28%29

Why should it show as a String when its supposed to return an object?

try:

listbox1.getItemAt(helper).label;

listbox1.getItemAt(helper).data;

then you have access to the strings inside

Translate
Guru ,
Jan 21, 2013 Jan 21, 2013

but still displaying it as object

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/SelectableList.html#g...

Why should it show as a String when its supposed to return an object?

try:

listbox1.getItemAt(helper).label;

listbox1.getItemAt(helper).data;

then you have access to the strings inside

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 21, 2013 Jan 21, 2013

thank you  a lot mr moccamaximum

it works like that , but i realy dont know why

can you pleases answer these 2 questions

1- "Why should it show as a String when its supposed to return an object" , why return

object?? as i know the text box only takes string values

2- what is the .label , also why we should write it in add item method   , i mean

why it shouldn,t be list.additem(object.text) not  list.additem({label:object.text}) because

in vb works like that

sorry because i asked a lot , but realy this thing confusing me  

thank you again 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
Guru ,
Jan 21, 2013 Jan 21, 2013

the text box only takes string values

the list juses a DataProvider object to save its data.

It has two public propertys label and data.

This is how its done with the "official" list component in AS3 anyway.

Drag an empty list compoennt from the components panel on stage,

mark it and go to the property/parameter section, then you can see it.

becausein vb works

you are kidding, I hope

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 21, 2013 Jan 21, 2013

thank you  , but only 1 question

why we cant do that

itemname11.text = listbox1.getItemAt({label:listbox1.selectedindex)

it makes more sense to me , because we gonna get item from the label and then

we need the index number

but i cant see this property(label) in the list methods , it is in data provider as i see , because of

that iam wondring from .label , i know not all the method should be in the properties

but still i cant understand the way , i mean .label..

can you explain more please

sorry again and thank you a lot 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
Guru ,
Jan 21, 2013 Jan 21, 2013

it makes more sense to me

Because you don`t see the "Bigger Picture".

The index-number of every entry in your list is Unique,

whereas its no problem to have multiple doubles of data or label.

It makes more sense to identify things on there unique properties.

So while the View of your application seems to point to the string that you select with your mouse.

Internally it points to the index of the dataProvider

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 21, 2013 Jan 21, 2013

i get it  :d

thank you alot moccamaximum

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 21, 2013 Jan 21, 2013

lol i guess iam confusing again

here

itemname11.text = listbox1.getItemAt(listbox1.selectedindex)

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
Guru ,
Jan 21, 2013 Jan 21, 2013

listbox1.getItemAt(listbox1.selectedindex).label

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 21, 2013 Jan 21, 2013

lol no not this , ididn,t complete it

here

lol i guess iam confusing again

here

itemname11.text = listbox1.getItemAt(listbox1.selectedindex)

if i do this without label i will get the numbers , right because it is array as i guess

but i tried to understand it more

now i want to see the label 1 or 2 and i wrote juice init

i was trying to do this   trace(listbox1.dataProvider.index[1] )

but i get error

and i realy dont know why

it says index error and some stuff     

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 21, 2013 Jan 21, 2013

sorry i didn.t explain it good

i revise the vb

here

http://www.youtube.com/watch?v=4kUoHNEpCmQ

in vb i can do this list.selected(itemnumber) but how can i do like this

in as3

sorry because my questions are too much

thank you

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
Guru ,
Jan 22, 2013 Jan 22, 2013
LATEST

Maybe this will help you:

1.Drag a List control from the components  panel on stage.

2.Name it "_List" in the property panel

3.Drag a TextArea component on stage

4.Name it "_TextArea"

5.Insert the following code on the first frame of your timeline

import fl.data.DataProvider;

var list_dp:DataProvider = new DataProvider();

for (var i:int = 0;i<5;i++){

list_dp.addItem( { label: "Label"+i,    data:i });

var _text:String = "Label"+i+"\n";

_TextArea.text += _text;

}

_List.dataProvider = list_dp;

_TextArea.height = _List.height;

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