I have a web application written in Flex and I am trying to create an AIR application from the same code base using conditional compilation.
In an AIR application, I need import statements, such as: import flash.data.SQLConnection; import flash.filesystem.File; but I cannot have these import statements in a web application because they are AIR classes.
I thought I could use conditional compilation to overcome this problem, but then I read the following at http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html : "You cannot use constant logical values to label metadata or import statements. "
If so, how can I have a common code base for Flex-based web applications as well as desktop applications? Has anyone solved this puzzle?
Thank,
Dilip
More on this subject after some testing and errors ... I have 3 projects in Eclipse for this project ... one for a web application, one for an AIR application and one for general source code. In the web and AIR project, I point to the common source code. In general code, I used conditional compilation, and it looks like you can do something like the following: CONFIG :: desktopMode {import flash.data.SQLConnection; import flash.events.SQLEvent; import flash.events.SQLErrorEvent; import flash.filesystem.File; }
and a similar approach for including web functions or individual AIR functions at compile time. This approach still works!
, , - Cairngorm. CONFIG:: desktopMode Cairngorm, " " "1131 ". , !