Search code examples
apache-flexairarraycollectioncodebase

How to separate ArrayCollection's into seperate files in Flex?


I build Adobe Air applications using Flex. After you introduce a few things like list of countries and list of nationalities in ArrayCollection format code gets messy and incredibly long.

Is it possible to place ArrayCollection's into separate files in the same Flex project, and then load them whenever needed, or upon compilation?


Solution

  • Yes; create a class in ActionScript that extends ArrayCollections and then hard codes the ArrayCollection's elements. Perhaps inside the constructor of your new class.

    You should be able to use this new class anywhere an ArrayCollection can be used.

    More info on creating classes in ActionScript.