Skip to main content
Šoški10369925
Participating Frequently
November 26, 2018
Answered

anyway to ignore import fail of not present class

  • November 26, 2018
  • 3 replies
  • 392 views

Hello,

I'm working on a project that needs to be deployed in AIR 13 for desktop and AIR 31 for Android (because of Android permission politics changed).

Of course, when I import PermissionStatus class and try to package for AIR 13 I get an error 1046: Type was not found or was not a compile-time constant: PermissionStatus.

I'm wondering is there any way to ignore this error so packager removes this import by itself and I don't need to remove any MovieClips or Library instances manually before packaging for lower versions of AIR SDKs?

TNX in advance.

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

Use conditional compilation.

https://divillysausages.com/2011/04/04/as3-conditional-compilation-or-ifdef-in-flash/

Like this:

CONFIG::AIR_IS_RECENT // Don't use 'if' for checking imports because 'if' is for runtime

{

    trace("air is recent");

    import flash.permissions.PermissionStatus;

}

Regards,

JC

3 replies

JoãoCésar17023019
Community Expert
Community Expert
November 26, 2018

Please see the comment above. I did some editions but now I think it will work.

Regards,

JC

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
November 26, 2018

Hi.

Use conditional compilation.

https://divillysausages.com/2011/04/04/as3-conditional-compilation-or-ifdef-in-flash/

Like this:

CONFIG::AIR_IS_RECENT // Don't use 'if' for checking imports because 'if' is for runtime

{

    trace("air is recent");

    import flash.permissions.PermissionStatus;

}

Regards,

JC

Šoški10369925
Participating Frequently
November 26, 2018

Perfect! Exactly what I was looking for.

Thank you very much!

JoãoCésar17023019
Community Expert
Community Expert
November 26, 2018

Excellent!

You're welcome!

Robert Mc Dowell
Legend
November 26, 2018

try{

     import clas.as;

catch(event:Event){}

Šoški10369925
Participating Frequently
November 26, 2018

Already tried, but without success.

The problem is, as I see it, the compiler firstly imports all the classes and after that it executes the code. Since try-catch is code side, it cannot prevent import.