Search code examples
javaactionscript-3

Can I use a .xml < context-param > as a constant in a .as class?


I work with .java and .as classes in my project. While in .java I can reference a "< context-param >" from .xml easily with

@Resource(name = "<context-param> name")
private String variableName;

I can't find the equivalent of @Resource for my .as classes.

Is there any way I can do something similar with my .as classes? I've looked into URLLoader, but it doesn't seem to be what I need.

I'm using IntelliJ Idea Ultimate 172.4574.19 on Ubuntu 19.04, if it matters.


Solution

  • So, what I managed to do was:

    I created another .as class where I declared all my constants with their respective String values, and called these constants from this .as class, as shown above.

    From ApplicationConstants.as:

    public static const EMAIL_EXAMPLE:String = "[email protected]";
    

    From the other classes:

    import com.myproject.ui.core.ApplicationConstants;
    EmailAddress.emailAddress = ApplicationConstants.EMAIL_EXAMPLE;