[FLEX 4 / AS3] I load a new component in a as3 file and I want to pass to it some data, knowing only it's a UIComponent.
ex:
// class1
// ...
_UIClass = getDefinitionByName(_basePath + _UIPath + '.' + _UIName) as Class;
_UI = new _UIClass();
// UI is a IVisualElement
// _UIClass is a Class, and in practice is a reference to the component MXML
// here I want to pass data, like this: _UI = new _UIClass开发者_JAVA百科(data); 
// or in another method like this: _UI.addData(data);
How do I do this?
You can use a cast to a class you created that you know has data in a certain place? Or you can use AS3's built in duck-typing. Or create another object that has your data and the UIComponent in it and pass that around. I think you may be wanting to do it wrong :-).
Final answer:
Use a common interface class and have your classes implement it.  Just straight up inheritance.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论