There is a section of the Flex 2 Developer's Guide (-> Using Flex Programming Language -> Using ActionScript -> Working with Flex components -> Referring to Flex components ) that talks about referring to flex components via the id of that component. The example given uses inline script, but it states :
"The IDs for all tags in an MXML component, no matter how deeply nested they are, generate public variables of the component being defined. As a result, all id properties must be unique within a document. This also means that if you specified an ID for a component instance, you can access that component from anywhere in the application: from functions, external class files, imported ActionScript files, or inline scripts." I cannot get this to work with an external AS file/class. I have created external ActionScript files which define classes which I import in my main application .mxml script section. For example, I have a TextArea component in my .mxml file with an id='messageLog'. I have a business object defined in an external AS file, which is imported in the inline SCRIPT section of the same .mxml file. Yes, the AS files are in the source path and resolve fine. Based on the Developer's Guide, within that object I should be able to do something like 'messageLog.text = "my message";'. I've even tried having a TextArea var within the business object, and trying to set that reference with Application.appliction.getChildByName("messageLog"), but that returns null as well. What am I missing? Is it a scope or namespace issue? The way I'm getting around it now is using set methods in the SCRIPT section to pass the Flex components into the AS classes (many of which are singletons, but that's another issue), but that seems like a hack, or at least not any kind of best practice. Thanks