Skip navigation
Currently Being Moderated

conditional compilation and import statements

Jun 10, 2011 11:30 AM

I have a web application written in Flex and I'm trying  to build an AIR application from the same code base using conditional  compilation.
In the AIR application, I need to have import statements  such as the following:
import flash.data.SQLConnection;
import  flash.filesystem.File;
but I cannot have these import statements in the web  application because they are AIR only classes.
I thought I could use conditional compilation to  overcome this issue but then I read the following on page http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf 69084-7abd.html:
"You cannot use constant Boolean values to conditionalize metadata or import statements."
If that's the case, how can I have common codebase for Flex based web as well as desktop applications? Has anyone solved this conundrum?
Thanks,
Dilip
 
Replies
  • Currently Being Moderated
    Jun 10, 2011 11:05 PM   in reply 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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 9:05 AM   in reply 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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 11:25 AM   in reply 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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points