Flex 4:1120:访问未定义的属性

发布于 2024-10-21 06:48:53 字数 973 浏览 5 评论 0原文

Flex 新手,我正在尝试使用 ArrayCollection 类,但我不断收到: 1120:访问未定义的属性,

例如:

var list:ArrayCollection = new ArrayCollection();

var item:Object = new Object();

list.addItem( item );

1120:访问未定义的属性 列表

第一行不是定义了数组列表吗?

更新时间:03-11 这是我的完整 mxml 文件:

    <?xml version="1.0"?>
<s:Application name="Spark_List_dataProvider_XML_test"
               xmlns:fx="http://ns.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>

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.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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无敌元气妹 2024-10-28 06:48:53

该代码工作得很好。看起来好像:

1)某些东西可能正在使用您的 ArrayCollection 作为 dataProvider,并且想要不存在的项目的属性
2)您有一个函数正在查找您要添加的项目的属性,但该属性不存在

请发布更接近您的真实代码、您的错误转储和/或引用 ArrayCollection 的内容以获取更多信息帮助。

检查错误转储中产生错误的类和行号,并查找可能存在的问题。

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.

黯淡〆 2024-10-28 06:48:53
<?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>
<?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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文