Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-30-2012, 11:01 AM   PM User | #1
Student1989
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Student1989 is an unknown quantity at this point
Combobox doesn’t react on text input from textfile

At this point I’ve got a combobox that gets its content from a SQLite database.
The user can select an item from the combobox or type the name of the item and then select it. When an item name is selected, the item is shown on the screen. Those functions work.

I made an open and a save function. The save function saves the name of the item in a text file. The open function opens the name of the item in the combobox. But then nothing happens. It doesn’t matter if I hit Enter. It seems that the combobox doesn’t recognize the text as input.

It is important to save and open the name of the item and not the item itself, because the item can be changed in the database. Then an old item would be shown and not the updated one.

I want the combobox to open the item when the item name is loaded in the combobox. What are the solutions for this problem?

This is the code that loads the name of the item in the combobox:

private function openComplete(e:Event):void
{
try
{
var data:ByteArray = fileRef.data;
combo.textInput.text = data.readUTFBytes(data.bytesAvailable);


}
catch(errObject:Error)
{
Alert.show("Foutmelding: " + errObject);
}
}
Student1989 is offline   Reply With Quote
Old 06-07-2012, 09:21 AM   PM User | #2
Student1989
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Student1989 is an unknown quantity at this point
I’ll try to explain the problem more clearly.

I want the name that is loaded from the textfile into the combobox to be selected from the list.
Once an item is selected everything works just fine. But I don't want the user to select the item, when the name is loaded into the combobox. The user will expect that the item will be selected automatically. Is that possible?

The function I want is the opposite of combobox.selectedItem. Instead of having a selected item and getting the name, I have a name and I want to select the item.

The name is a correct name, because the name is saved from the combobox.
Student1989 is offline   Reply With Quote
Old 06-07-2012, 03:57 PM   PM User | #3
djpaul1963
New Coder

 
Join Date: Apr 2012
Location: Athens GR
Posts: 57
Thanks: 0
Thanked 6 Times in 6 Posts
djpaul1963 is an unknown quantity at this point
You must trigger the combobox onselect event programatically to achieve that.
djpaul1963 is offline   Reply With Quote
Old 06-08-2012, 09:54 AM   PM User | #4
Student1989
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Student1989 is an unknown quantity at this point
I found the problem.
I’ve tried to loop through the array of names before. It got me thinking. It had to work, but it didn’t.

for (i = 0; i < this.dataprovider.length ; i++){
if(this.dataprovider.getItemAt(i).name == name ){
combo.selectedIndex = i;
break;
}
}

I found out that when I looped throught the data, the method that opened the item wasn't used anymore. In the combobox I used change to call the method.
When I use caretChange instead of change, the method is used.

So when I open the file with the itemname, the itemname is loaded in the combobox and the item is opened on the screen.
Student1989 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:02 PM.


Advertisement
Log in to turn off these ads.