In the AIR application I'm developing, I'm using a local SQL Lite
database, it's been working well, however, after a bit of refactoring, I
came across this error:
"RangeError: Index '1' specified is out of bounds."
In this case, '1' is the index of the very first item in the datatable,
automatically incremented from '0' when the very first item was first
entered in the previously empty datatable. However when the index of the
selected item is taken from the very first item of the dataGrid's
dataProviders(ArrayCollections), they read as '0' which is usually the
first index of just about anything. Here's a snippet of code where the
error usually occurs:
public function newEdit():void
{
chosenMode = "Edit";
currentState="Edit Item";
this.deleteCol.visible = false;
this.editCol.visible = false;
this.btnNew.enabled = false;
this.btnExit.enabled = false;
this.txtName.text = "";
this.txtID.text = "";
selectedItemIndex =
this.dgUsage_Locations.selectedItem.UniqueID;//Generally turns out to be
'1'
uniqueID =
useLocDataProvider.getItemAt(selectedItemIndex).UniqueID;//When taken
from the datatable it is '0'
this.txtID.text =
useLocDataProvider.getItemAt(selectedItemIndex).UseLocationID;
this.txtName.text =
useLocDataProvider.getItemAt(selectedItemIndex).UseLocationName;
}
I can think of a few workarounds for this problem, such as incrementing
the value taken from the dataProvider since it seems like it will always
be one lower than what is actually in the database, or I can simply code
it so that the first entry entered into the datatable is always 0,
however I'm not sure that either of these will work 100%. So any
suggestions to solve this issue would be helpful. Thanks in advance.
Brian Ross Edwards
Tech-Connect LLC.