Hi Marco I fixed it in the first loop i need to get rid of -1 to finish the loop correctly, its been fixed now Thanks for your help Anuj
On Fri, Dec 12, 2008 at 4:02 AM, Marco Catunda <[email protected]>wrote: > Anuj, > > I think there is something wrong with this structure. Why make it into for > loop? > The _addToAssociatedDevicesArr is received the same value > > > for(var i:*=0;i<_addDevicesLen-1;i++) > { > _addToAssociatedDevicesArr=nvrsInPoolList.selectedItems; > } > > The last loop has the same problem. The index variable t is never used. > Why it is in for loop? > > for(var t:*=0;t<_addToAssociatedDevicesArr.length;t++) > { > if(nvrsInPoolList!=null) > { > > IList(nvrsInPoolList.dataProvider).removeItemAt(nvrsInPoolList.selectedIndex); > } > } > > About the problem you complain > > I think one of this variable is null value: > > camerasInPoolList > arrAddToPool > arrRemoveFromPool > > -- > Marco Catunda > > > On Thu, Dec 11, 2008 at 7:33 PM, anuj181 > <[email protected]<anuj181%40gmail.com>> > wrote: > > Hi Guys > > I am trying to implement the delete entries of the list box. The code > > works fine till the last entry, when i am trying to delete the last > > item after selection it is throwing error TypeError: Error #1009: > > Cannot access a property or method of a null object reference. > > I have seen this error so many times but I am not sure how will i fix > > this in the following code. Please help me in fixing this error > > Thanks > > Anuj > > > > /*CODE*/ > > > > <mx:Button x="322" y="237" label="Add" id="_addButton" > > click="addToAssociatedDevices(event)"/> > > > > private function addToAssociatedDevices(evt:MouseEvent):void > > { > > var _addDevicesLen:int=devicesInList.length; > > var _addToAssociatedDevicesArr:Array; > > > > > > for(var i:*=0;i<_addDevicesLen-1;i++) > > { > > _addToAssociatedDevicesArr=nvrsInPoolList.selectedItems; > > > > > > } > > if((_addToAssociatedDevicesArr is > > Array)&&(_addToAssociatedDevicesArr!=null)) > > { > > var removeIndex:int = 0; > > for each (var addItemVal:* in _addToAssociatedDevicesArr) > > { > > if(addItemVal!=null) > > { > > > > IList(camerasInPoolList.dataProvider).addItem(addItemVal as Object); > > //Adds a device to the Add To Camera Pool list > > arrAddToPool.push(addItemVal); > > //Removes a device from the Remove From Pool list > > removeIndex = arrRemoveFromPool.indexOf(addItemVal); > > if(removeIndex > -1) { > > arrRemoveFromPool.splice(removeIndex,1); > > } > > } > > } > > > > } > > for(var t:*=0;t<_addToAssociatedDevicesArr.length;t++) > > { > > if(nvrsInPoolList!=null) > > { > > > > > IList(nvrsInPoolList.dataProvider).removeItemAt(nvrsInPoolList.selectedIndex); > > } > > } > > } > > > > > >

