Flex 编译时间常数 - 时间戳
我正在尝试使用 Flex 编译时间常量 包含 SWF 的构建日期和时间(源代码控制修订/时间戳,例如 SVN:Keywords 不足以满足我们的需求,我们需要知道实际的构建时间,而不是提交时间)。
我尝试过使用actionscript(就像文档建议你应该能够这样做):
-define+=COMPILE::Timestamp,"new Date()"
但这给出了“配置值的初始值设定项必须是编译时常量”
我尝试将其放入shell并使用date命令(使用各种单引号和双引号配置),例如:
-define+=COMPILE::Timestamp,`date +%Y%m%d%H%M%S`
我只能让它使用简单的字符串和简单的常量表达式(例如,我可以执行 4-2
,它会是 2
在运行时。但我无法让它做任何在我声明定义时其值无法明确知道的事情。
有没有人有这样的运气?
I'm trying to use Flex Compile Time Constants to include the date and time the SWF was built (source control revision/timestamp such as SVN:Keywords is not sufficient for our needs, we need to know the actual build time, not the commit time).
I've tried using actionscript (like the documentation suggests you should be able to):
-define+=COMPILE::Timestamp,"new Date()"
But this gives "The initializer for a configuration value must be a compile time constant"
I've tried getting it to drop to shell and use the date command (using various single and double quote configurations), for example:
-define+=COMPILE::Timestamp,`date +%Y%m%d%H%M%S`
I can only get it to work with simple strings and simple constant expressions (eg, I can do 4-2
and it'll be 2
at runtime. But I can't get it to do anything whose value wouldn't be explicitly known at the time I declare the define.
Has anyone had any luck with something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,最终使用这篇博文作为起点。对我来说效果非常好。只需将类的一些部分更新为 Flex 4。从编译的 swf 中直接提取日期。
I had the same problem and ended up using this blog post as a starting point. Worked really well for me. Just had to update a few bits of the class to flex 4. Pulled the date right out of the complied swf.
您的问题的关键很可能是 Adobe 引用编译时间常量的以下声明:
常量可以是布尔值、字符串或数字,也可以是可以在编译时在 ActionScript 中计算的表达式。
我假设时间戳在编译时不可用。
但是,您可以尝试使用字符串(类似这样)
另一个想法是您可以从编译的文件中获取信息。
希望这有帮助。
The key to your problem is most likely in the following statement by Adobe referring to Compile Time Constants:
The constant can be a Boolean, String, or Number, or an expression that can be evaluated in ActionScript at compile time.
I would assume that the Timestamp is not available at compile time.
However, you may try using a string instead (something like this)
Another thought is that you could get the information from the compiled file.
Hope this helps.
经过广泛的研究,我得出的结论是,这根本不可行。
After extensive research, I've concluded that this simply isn't doable.
如果您不使用 FlexBuilder 进行构建,您也可以轻松完成。
我在 Maven 中使用 FlexMojos 做了类似的事情。
在相关的配置部分中:
由于您提到的原因,FlexBuilder 作为构建环境非常糟糕
If you don't use FlexBuilder to do your builds you can do it quite easily.
I do something like this with FlexMojos in Maven.
In the relevant config section:
FlexBuilder pretty much sucks as a build environment for reasons like the one you mention