actionscript-3 - 1120 : Access of undefined property [instantiated variable]?(灵活)

标签 actionscript-3 apache-flex compiler-errors flex4.5 undefined-reference

我看过像 this 这样的问题, this , thisthis ,但这些似乎都没有描述我的问题?

我声明这些变量:

<fx:Script>
    <![CDATA[
        import assets.Page;
        public var oneTwo:Page = new Page("...");
        public var oneThree:Page = new Page("...");
        protected var oneFour:Page = new Page("...");
        protected var oneFive:Page = new Page("...");
        protected var oneSix:Page = new Page("...");

... 正在引用确实存在的对象,并且 Flex 可以使用每个项目的构造函数。接下来,我尝试设置这些对象的其他属性:
        oneThree.next = oneFour;
        oneThree.prev = oneTwo;
        oneFour.next = oneFive;
        oneFour.prev = oneThree;
        oneFive.next = oneSix;
        oneFive.prev = oneFour;

等等。现在,当我单击其中的每一个时,Flex 会突出显示每个实例中的变量,并在编码期间将它们全部识别为有效。但编译给出:
-1120: Access of undefined property oneThree.
-1120: Access of undefined property oneFour.
-1120: Access of undefined property oneFour.
-1120: Access of undefined property oneFive.

依此类推,每次使用每个变量时使用一次(此处的情况为十二次)。您可以看到我将一些公开和一些 protected ,这似乎没有什么区别。

最佳答案

[This][1] 问题使我找到了解决方案。

第二个代码块中的变量需要在它们自己的函数中进行编辑,得到:

<fx:Script>
    <![CDATA[
        import assets.Page;
        public var oneTwo:Page = new Page("...");
        public var oneThree:Page = new Page("...");
        protected var oneFour:Page = new Page("...");
        protected var oneFive:Page = new Page("...");
        protected var oneSix:Page = new Page("...");

        oneThree.next = oneFour;
        oneThree.prev = oneTwo;
        oneFour.next = oneFive;
        oneFour.prev = oneThree;
        oneFive.next = oneSix;
        oneFive.prev = oneFour;
    ]]>
</fx:Script>

而不是这个:
<fx:Script>
    <![CDATA[
        import assets.Page;
        public var oneTwo:Page = new Page("...");
        public var oneThree:Page = new Page("...");
        protected var oneFour:Page = new Page("...");
        protected var oneFive:Page = new Page("...");
        protected var oneSix:Page = new Page("...");

        protected function _init():void
        {
            oneThree.next = oneFour;
            oneThree.prev = oneTwo;
            oneFour.next = oneFive;
            oneFour.prev = oneThree;
            oneFive.next = oneSix;
            oneFive.prev = oneFour;
        }
    ]]>
</fx:Script>

这为我解决了错误。希望这对其他人有帮助!

关于actionscript-3 - 1120 : Access of undefined property [instantiated variable]?(灵活),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10997421/

相关文章:

android-ndk - 编译tesseract时出错

c++ - MinGW 中的 fatal error : strtok_r. h : No such file or directory (while compiling tesseract-ocr-3. 01)

c# - 具有可选参数和 new() 约束的构造函数?

apache-flex - 如何在Flex中控制Spark Datagrid的滚动器位置?

apache-flex - trace() 在 Flash Builder 4 中不起作用?

apache-flex - FlexBuilder 如何编译我的应用程序?

apache-flex - 柔性 : Displaying more than 5 things at a time in a DropDown (ComboBox)

apache-flex - actionscript 或 flex 中是否有换行常量

actionscript-3 - 使用 AS3 绘制部分圆时角度错误

ios - 如何在Adobe AIR应用程序中强制iPad上的风景和iPhone中的人像?