开发者

I load a new component in a as3 file and I want to pass to it some data, knowing only it's a IVisualElement

[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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜