在 Flex 中,皮肤和 itemRenderer 之间有什么区别?
事实上,它们(皮肤和 itemRenderers)似乎都使用 flash.graphics.* 包进行绘图。我之前在皮肤和itemRenderers之间复制粘贴了代码,所以我真的不明白其中的区别。我在实现 itemRenderers 方面比在皮肤方面有更多的经验,所以这可能是问题的一部分。谢谢,请告诉我。
Indeed they both (skins and itemRenderers) seem to do drawing using the flash.graphics.* package. I have copy pasted code between skins and itemRenderers before, so I really don't understand the difference. I have had more experience implementing itemRenderers than skins, so that might be part of the problem. Thanks, let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
皮肤是一种可以应用于各种 UIComponent 的图形元素。容器可以有 borderSkins,按钮可以有各种上/上/下皮肤。它们可以通过多种方式实现,包括使用绘图 API(“程序化皮肤”)或通过嵌入资产(“图形皮肤”)。皮肤通常非常轻量级,可能只是 Flash DisplayObject 而不是 Flex UIComponent,后者更重量级,但包含更多功能。
itemRenderer 通常是一个 UIComponent,基于列表的控件使用它来显示项目。使用 DataGrid/DataGridColumn 时通常也会使用 itemRenderers。大多数使用 itemRenderer 的组件都会回收它们,这意味着它们会创建屏幕上显示所需的数量,并且当用户滚动数据时,相同的 itemRenderer 会重新定位并插入新数据。这就是列表和 DataGrid 可以支持大量数据的原因之一,也是为什么尝试使用 Repeater 完成类似的事情会导致应用程序性能糟糕的原因之一。
A skin is a graphical element that can be applied to various UIComponents. Containers can have borderSkins and Buttons can have various up/over/down skins. They can be implemented in several ways, including the use of the drawing API ("Programmatic skins") or through embedding assets ("Graphical skins"). Skins are usually pretty lightweight and may only be a Flash DisplayObject rather than a Flex UIComponent, which is more heavyweight but contains much more functionality.
An itemRenderer is typically a UIComponent that a List-based control uses to display an item. You also usually use itemRenderers when using a DataGrid/DataGridColumn. Most components that use itemRenderers recycle them, meaning that they create about as many as are needed to display on the screen, and as the user scrolls through the data the same itemRenderers are repositioned and get new data plugged into them. This is one of the reason why Lists and DataGrid can support large quantities of data and why trying to accomplish similar things with a Repeater leads to apps with terrible performance.