简体   繁体   English

Flex声明顺序错误

[英]Flex Declaration Order Bug

In Flex you can use Declarations tags fo non UI elements. 在Flex中,您可以使用UI元素的声明标签。

Problem : The order of classes inside the Declaration is sorted ascending or something... 问题 :声明中的类顺序是升序排序或其他...

Meaning that in this example, AClass will be instantiated before BClass: 这意味着在此示例中,将在BClass之前实例化AClass:

<fx:Declarations>
    <local:AClass />
    <local:BClass />
</fx:Declarations>

But in the next example, AClass will STILL be instantiated before BClass even though BClass is first. 但是在下一个示例中,即使BClass是第一个,AClass仍将在BClass之前实例化。 This is unexpected behavior because AClass may depend on BClass but will instantiate first even though it comes afterwards in the declaration order. 这是意外的行为,因为AClass可能依赖于BClass,但是将首先实例化,即使它以声明顺序出现在后面。

<fx:Declarations>
    <local:BClass />
    <local:AClass />
</fx:Declarations>

AClass 一类

public class AClass
{
    public function AClass()
    {
        var _instance:Object = BClass.instance;
        trace("AClass " + _instance);
    }   
}

And BClass 和BClass

public class BClass
{   
    private static var _instance:Object;
    public function BClass()
    {
        _instance = new Object();
        trace("BClass " + _instance);
    }

    public static function get instance():Object{
        return _instance;
    }
}

Am I crazy? 我疯了吗?

I just did a quick test by inspecting the generated actionscript (use the -keep flag as an extra compiler argument) and the order of declaration seems to be preserved correctly. 我只是通过检查生成的动作脚本(使用-keep标志作为额外的编译器参数)进行了快速测试,并且声明的顺序似乎正确保留了。

Are you sure you did a clean compile after changing the order of the objects? 您确定更改对象的顺序后进行了干净的编译吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM