0

我看过这样的问题,这个,这个这个这些似乎都没有描述我的问题?

我声明这些变量:

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

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

4

1 回答 1

0

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

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

于 2012-06-12T13:36:25.440 回答