text: conditional compilation and import statementsDilipShah Jun 10, 2011 11:30 AM
  import flash.data.SQLConnection;
  import flash.filesystem.File;
  "You cannot use constant Boolean values to conditionalize metadata or import statements."
  1. Re: conditional compilation and import statementsFlex harUI Jun 10, 2011 11:05 PM (in response to DilipShah)
  If the import is resolvable, but not used, I think you will be ok. So
  conditionalize the use of the classes, leave the imports in and use the AIR
  config and see if it runs on the web.
  2. Re: conditional compilation and import statementsDilipShah Jun 13, 2011 9:31 AM (in response to Flex harUI)
  Even though Adobe document mentions that "You cannot use constant Boolean values to conditionalize metadata or import statements.", I've managed to do so and it seems to work so far. There is just one exception though. If I add such conditions around import statements in my Cairngorm Model Locator class, I get "Uncaught exception in compiler" or "1131 classes must not be nested" error.
  Here is how I have it in my code:CONFIG::desktopMode {
  import flash.data.SQLConnection;
  import flash.events.SQLEvent;
  import flash.events.SQLErrorEvent;
  import flash.filesystem.File;
  }
  It surely is a bit mysterious!
  3. Re: conditional compilation and import statementsCyberProdigy Apr 2, 2013 9:05 AM (in response to DilipShah)
  DilipShah, as far as I see the classes are still included if referenced by import.
  Example:
  I have this statement in my class A
  if(CONFIG::platform == "ios") {
  import B;
  }
  I can see in linkreport that class B is still included and is included because A is referencing it.
  Flex harUI, classes are included into final swf file if any other class is referencing it through import even though not using it. I've experimented with it quiet a bit.
  4. Re: conditional compilation and import statementspauland Apr 2, 2013 11:25 AM (in response to CyberProdigy)
  CyberProdigy, the if statement is a run-time construct, not compile time, you can't use it for conditional assembly of the code.
  DilipShah has the right idea, I think, but you'll have to use the same technique to eradicate all trace of the use of B for it not to be included.