Flex 4: 1120: Access of undefined property
New to Flex and I am trying to work the the ArrayCollection class and I keep getting: 1120: Access of undefined property
Something like:
var list:ArrayCollection = new ArrayCollection();
var item:Object = new Object();
list.addItem( item );
1120: Access of undefined property list
Isn't the array list being defined in the first line?
Updated: 03-11 Here is my full mxml file:
<?xml version="1.0"?>
<s:Application name="Spark_List_dataProvider_XML_test"
xmlns:fx="http://ns开发者_StackOverflow社区.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
var list:ArrayCollection = new ArrayCollection();
var item:Object = new Object();
list.addItem( item );
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
</s:Application>
That code works just fine. It appears as though:
1) something might be using your ArrayCollection as a dataProvider, and wants a property on the items that isn't there 2) you have a function that is looking for a property on the items that you are adding, and the property isn't there
Please post something closer to your real code, your error dump, and/or what is referencing the ArrayCollection for additional help.
Check the error dump for the class and line number that is producing the error and look there for what the problem might be.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
creationComplete="init(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
protected function init(event:FlexEvent):void
{
// TODO Auto-generated method stub
var lista:ArrayCollection = new ArrayCollection();
var item:Object = new Object();
lista.addItem(item);
}
]]>
</fx:Script>
</s:Application>
精彩评论