简体   繁体   中英

Flex Declaration Order Bug

In Flex you can use Declarations tags fo non UI elements.

Problem : The order of classes inside the Declaration is sorted ascending or something...

Meaning that in this example, AClass will be instantiated before BClass:

<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. This is unexpected behavior because AClass may depend on BClass but will instantiate first even though it comes afterwards in the declaration order.

<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

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.

Are you sure you did a clean compile after changing the order of the objects?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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