You will get a different answer from everyone who answers you. There are many definitions of "best practice" and it all depends on how you set up your project, the type of third-party framework you use, if any, and other factors.
If you are just using the Flex framework, consider creating a singleton class (in ActionScript) to hold all of your data. Then each component can just bind to the data in that singleton. The components read/write to the data in the class, and then they all get updated simultaneously. You don't have to be concerned if a child component in the viewstack is created yet, it will get whatever data it is bound to when it does get created.
I was thinking of doing that, but was worried it's bad practice to use Singletons. There's many who argue against using them in AS3.
It seems like a good idea to me though.
1 person found this helpful
You're right lots of people complain about using singletons. I won't pretend to be an expert on this subject. You can also read up on the various patterns used for large-scale applications and see if it's worth your time to implement one of them. I think eventually you'll decide based on what's good for you and your workflow. I use a data singleton and a 'front controller' (event handler & related logic) to manage the events in conjunction with a central event dispatcher used by the components. All are singletons and so there can only be one instance of them, shared by all components. Nothing too deep really but at least I've got things organized where I can find them easily enough. Maybe others here can steer you in a different direction.In the end, you'll probably store all your data and related functions in a single file accessible by all components, I think. HTH
P.S. Ping UbuntuPenguin; he seems well-versed on this subject.
Yeah, that's pretty much how I do it as well with an extra Database singleton.