I think you confused about the domain of the variable, "ac_php_results" just could be directly used in Application domain.
I think you should create other singleton class to used between Application and your custom Component.
See this example on how you establish connection between two MXML components w/o using Application.application
Besides, avoid underscores in the variable names, this is because you don't know how generated methods / getters / setters are called, and if you do put underscores in the variable names you have a good chance to have a name collision with the generated ones.
Yet another thing - MXML file names should start with the capital letter, this is because they are classes.
More than that, if you do need a global access to the variable, this should light you a red bulb, as in general global variables, singletones and such are considered bad practice. This is becuase it makes your code into non reusable, which makes you loose one of the advantages of OOP approach - reusability / incapsulation.
Sorta defeats the purpose of the custom component i.e. an independant module. You could define a public variable in your custom component. Import the component into the main app (as you are now doing) and then set this public variable from the main app i.e.
In your custom component:
public var ac_php_results_from_app:ArrayCollection;
In the main app:
then once ac_php_results are received:
ListaPolis.ac_php_results_from_app = ac_php_results.
You thought is in the right way!
It's bad practice referencing to Application pointer.
Generaly says you should split you application into Model-Control-View. In a Model you will store all data that came from server. View should take its data from Model. And in a Control you do populating Model's data.
I'm afraid this example is too complicated for me, because I just start with Flex :-((
Could you give me simpler example?
I check that even I want to use variable in my application's main file:
THIS WAY WORKS:
BUT THIS DOESN'T:
In main.as file I have declared:
public var ac_php_results:ArrayCollection = new ArrayCollection();
main.as file is a file where I declare a few variables which I would like to use in many different custom components
Sounds to me you have to define many global variables. See this page for some code to solve your problem:
You can define all your globals in the model locator that you can then import into any of your components. Note that you don't really need to use Cairngorm - the article explains how, quoting ...
"This code may look a bit daunting in the beginning, but trust me that it is not as difficult as it may appear. First, we have our package definition and we import some classes. Right now we know that we will need the IModelLocator interface. To use this you will need the Cairngorm SWC that can be found here: Cairngorm. Also note - you could build a model locator without Cairngorm, and I do this frequently on small projects (you just leave out the 'implements IModelLocator' and 'import com.adobe.cairngorm.model.IModelLocator' code from the Model Locator)."
You are right. This article is very useful. I did as the author said, and it works.
This is the solution that I needed. Now I can store in one place all variables (which doesn't change in time, but are loaded from MySQL database) and use it in many controls and components.
I have to look closer to Cairngorm, it seems to be useful framework.