闪光/ Flex的条件编译"否则" [英] Flash/Flex conditional compilation "else"

查看:158
本文介绍了闪光/ Flex的条件编译"否则"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AS3中,你可以通过一个常数编译器

In AS3 you can pass a constant to the compiler

-define+=CONFIG::DEBUG,true

和使用它的条件编译如下所示:

And use it for conditional compilation like so:

CONFIG::DEBUG {
   trace("This only gets compiled when debug is true.");
}

我正在寻找像#ifndef的,所以我可以否定调试的值,并用它来有条件地释放增加code。我发现的唯一的解决办法,到目前为止是在条件编译文档在Adobe和因为我的调试和发布配置是相互排斥的,我不喜欢有调试版本和发布常量的想法。

I'm looking for something like #ifndef so I can negate the value of debug and use it to conditionally add release code. The only solution I've found so far was in the conditional compilation documentation at adobe and since my debug and release configurations are mutually exclusive I don't like the idea of having both DEBUG and RELEASE constants.

此外,这种格式的作品,但我猜想,它的运行运行时检查是不是我想要的:

Also, this format works, but I'm assuming that it's running the check at runtime which is not what I want:

if (CONFIG::DEBUG) {
   //debug stuff
}
else {
   //release stuff
}

我也算是做这样的事情,但它仍然不是完美的解决方案我所期待的:

I also considered doing something like this but it's still not the elegant solution I was hoping for:

-define+=CONFIG::DEBUG,true -define+=CONFIG::RELEASE,!CONFIG::DEBUG

在此先感谢:)

Thanks in advance :)

推荐答案

使用了的if / else 结构:在死code将被删除编译器并不会在运行时进行测试。你将有只有一个版本,你的code在SWF。

Use the if / else construct : the dead code will be removed by the compiler and it will not be tested at runtime. You will have only one version of your code in your swf.

如果您不能确定使用反编译或转储工具,看看到底发生了什么。

If you are not sure use a decompiler or a dump tool to see what really happens.

<一个href="http://apparat.google$c$c.com/files/dump.zip">http://apparat.google$c$c.com/files/dump.zip

http://www.swftools.org/

...

这篇关于闪光/ Flex的条件编译&QUOT;否则&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆