我想创建一个组件,其中有两个“漏洞”,每次使用时填充的方式都不相同。目前,我做这样的(在本例中使用Flex 4框架---它会寻找的Flex 3几乎相同):使用占位符创建Flex组件的好方法是什么?
public var fooComponent : IVisualElement;
public var barComponent : IVisualElement;
override protected function createChildren() : void
{
super.createChildren();
fooContainer.addElement(fooComponent);
barContainer.addElement(barComponent);
}
<Group id="fooContainer"/>
<!-- ... other components ... -->
<Group id="barContainer"/>
这种运作良好,但它是一种很多的代码来写这么简单的东西。
我想什么是这样的:
[Bindable] public var fooComponent : IVisualElement;
[Bindable] public var barComponent : IVisualElement;
<Placeholder content="{fooComponent}"/>
<!-- ... other components ... -->
<Placeholder content="{barComponent}"/>
现在,我可以实现的占位符组件自己,但我不禁想,如果没有更好的办法来做到这一点使用Flex框架中的现有工具。
从理论上讲,用适当的编译器的支持,它甚至可以归结为这样的事:
<Placeholder id="fooComponent"/>
<!-- ... other components ... -->
<Placeholder id="barComponent"/>
不是我一直在寻找的答案(我已经阅读过这篇文章,可能已经有几次了),但我怀疑我会得到一个更好的答案,这无疑是一个相关的链接,所以我只是要去接受这个。我现在也意识到现在我的问题在StackOverflow中的表现有多糟糕 - 在创建它时我在这里是非常新的,并且我添加了赏金可能更多地尝试赏金的概念而不是获得实际答案。无论如何,谢谢你给它一个镜头。我确信这个链接对将来遇到这个问题的人有用。 – 2011-10-04 18:11:56