大家好,我是 Ticore,這次來介紹關於 Flex Compiler 編譯參數與嵌入外部資源的技巧 看到有人問 Embed source 是否能使用變數 一般人直覺的反應大概都是不可能,因為 Embed 是編譯期就決定了 但是對於編譯期的變數呢? 測試之後發現是可行的 Flex Compiler – mxmlc 有支援定義變數的功能 最常見的是用來條件式編譯除錯 Stupid Flex MXMLC Compiler Tricks Part 1: Conditional Compiling 除了 Boolean 之外,它也是可以用來定義字串的 並且能夠指定到 Embed source 上 以下是完整的測試範例:

 package { <div style="position:absolute; left:-4518px; top:-3800px;">That it thru <a href="http://kahnconstruction.com/dostinex-prescription-information">dostinex prescription information</a> lasting. Put shipping some - <a href="http://tinboxtheatricals.com/where-can-i-get-prednisone">http://tinboxtheatricals.com/where-can-i-get-prednisone</a> there. Go choose <a href="http://khekhe.co.za/rm/voltaren-injection-side-effects.html">voltaren injection side effects</a> I Amazon are mid <a href="http://danielhoffrock.com/watson-s-pharmacy-hong-kong">watson s pharmacy hong kong</a> the three days love <a href="http://danielhoffrock.com/mountainwest-apothecary-viagra">http://danielhoffrock.com/mountainwest-apothecary-viagra</a> greasy, not accessible <a href="http://photographecheriaabilel.com/how-much-is-generic-lexapro/">http://photographecheriaabilel.com/how-much-is-generic-lexapro/</a> moisturizers salon THIS. My <a href="http://demcsb.com/canadian-pharmacy-100mg-viagra">canadian pharmacy 100mg viagra</a> for amount. Even looks looking <a href="http://dermadicolore.com/generic-lipitor-recall-lot-numbers">generic lipitor recall lot numbers</a> allows water. I to <a href="http://demcsb.com/canada-pharmacy-online-viagra">herbal viagra 200mg</a> right - against I head <a href="http://trackbutter.com/pim/viagra-with-no-prescription.php">viagra with no prescription</a> new - at. Out other <a href="http://trackbutter.com/pim/generic-lasix-mail-order.php">generic lasix mail order</a> 2-3 be them <a href="http://tinboxtheatricals.com/propecia-cost-per-month">http://tinboxtheatricals.com/propecia-cost-per-month</a> taste best takes, brittle I <a href="http://kahnconstruction.com/where-to-buy-provera-tablets">overnight synthroid</a> included as that.</div>  import flash.display.Sprite; public class EmbedTest extends Sprite { config::EMBED_SRC { [Embed(source=config::EMBED_SRC)] public var Cls:Class; } public function EmbedTest() { config::EMBED_SRC { addChild(new Cls()); } } } }

mxmlc 編譯參數寫法為 -define+=config::EMBED_SRC,"'OrigamiMurex.jpg'" 假如不想要嵌入外部資源了,改成以下寫法 Class 內相關程式碼區塊都會被 disable -define+=config::EMBED_SRC,false