A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [CS3] AS2, making dynamic combobox interactive

  1. #1
    Member
    Join Date
    May 2008
    Posts
    40

    [CS3] AS2, making dynamic combobox interactive

    So far I have populated the combobox from a PHP script and a MySQL database.

    Problem is I have to make each item inside the combobox clickable - I want a textbox to be filled with the value I click on.

    My actionscript skills are not that good so hints would be appreciated.

    This is my code so far:

    Code:
    //populating the combobox "dropDown"
    function AddItems(Regions_in)
    {
    	var my_str:String = Regions_in;
    	var my_array:Array = my_str.split(":");
    
    	for (i=0; i<my_array.length; i++)
    	{
    		region_combobox.addItem(my_array[i]);
    		
    		// I am not sure how I would add a listener here 
    	}
    }
    Thanks anyone

  2. #2
    Member
    Join Date
    May 2008
    Posts
    40
    Okay... so I tried this aswell as many other things and I get undefined as the result inside the textbox - please explain why I get undefined.

    Code:
    //populating the combobox "dropDown"
    function AddItems(Regions_in)
    {
    	var my_str:String = Regions_in;
    	var my_array:Array = my_str.split(":");
    
    	for (i=0; i<my_array.length; i++)
    	{
    		region_combobox.addItem(my_array[i]);
    		
    		postcode_search.text = region_combobox.selectedItem.data;
    	}
    }
    Cheers

  3. #3
    Member
    Join Date
    May 2008
    Posts
    40
    tumble weed passes by...

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    function AddItems(Regions_in){
    var 
    my_str:String Regions_in;
    var 
    my_array:Array = my_str.split(":");
    for (
    i=0i<my_array.lengthi++){
    region_combobox.addItem(my_array[i]);
    }
    };

    AddItems("Select:EX5:EX7:EX8");

    obj = new Object;
    obj.change = function(comp){
    lab comp.target.selectedItem.label;  // trace(lab);
    postcode_search.text lab;
    };
    region_combobox.addEventListener("change"obj); 
    hope this example helps you on your way

  5. #5
    Member
    Join Date
    May 2008
    Posts
    40
    That worked a charm....

    Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center