Apache flex flashbuilder条件编译问题

Apache flex flashbuilder条件编译问题,apache-flex,flash-builder,conditional-compilation,Apache Flex,Flash Builder,Conditional Compilation,如何在Flex项目中执行以下操作 package{ #ifdef BAR class Foo{ ...implementation of Foo.... } #else class Foo{ ...alternative implementation of Foo } #endif } 如果我尝试使用以下编译器语句 -定义配置::BAR,true -定义配置::NOBAR,false 并以这种方式对其进行编程: package

如何在Flex项目中执行以下操作

package{

#ifdef BAR
    class Foo{
        ...implementation of Foo....
    }

#else
    class Foo{
        ...alternative implementation of Foo
    }
#endif
}
如果我尝试使用以下编译器语句 -定义配置::BAR,true -定义配置::NOBAR,false

并以这种方式对其进行编程:

package{

CONFIG::BAR{
    class Foo{
        ...implementation of Foo....
    }
}

CONFIG::NOBAR{
    class Foo{
        ...alternative implementation of Foo
    }
}
}
然后flash builder给了我一个编译错误:

1018: Duplicate class definition: Main
如何解决这个问题?

请看一看。看起来不需要将类放入
{}
块中

如果文档是正确的,这应该可以:

package{

    CONFIG::BAR
    class Foo{
        ...implementation of Foo....
    }

    CONFIG::NOBAR
    class Foo{
        ...alternative implementation of Foo
    }
}

通常,如果您想这样做,而不是以两种不同的方式定义类,您可以定义同一类的两个不同子类(或者两个实现相同接口的不同类,如果需要)。然后在#ifdef子句中,将正确的子类分配给引用变量。然后其余的类将引用该变量,并获得所需的类定义