让用户在运行时选择样式的最佳方式 - Flex
我想做的事情:允许用户通过从带有各种图标的下拉菜单中进行选择来为自定义组件选择调色板。
我已将下拉菜单部分放下,但我试图了解如何最好地处理代码中的各种样式。理想情况下,我希望能够在运行时加载样式,但我认为这没有什么主要优势,所以我现在正在考虑以所有样式进行编译。尽管如此,我似乎找不到一种合适的方法来构建代码。破解它似乎非常简单/快速,但是有一种比拥有一个大的值数组更好的方法,这些值可以通过与每个图标关联的某个索引来索引 - 哎呀!
很想听听您的想法或看到任何解决此问题的明显方法的指示。
谢谢你!
弗雷德
What I'm trying to do: allow a user to be able to select a color palette for a custom component by selecting from a drop down menu with a variety of icons.
I have the drop down menu part down, but I'm trying to understand how to best handle the various styles in my code. Ideally I would have liked to be able to load styles at run time, but I don't see a major advantage with this so I'm now thinking about compiling in all styles. Still, I can't seem to find a decent way to structure the code. Hacking it seems pretty easy / fast, but there's got a better way than having a big fat array of values which can be indexed via some index associated with each icon - yuck!
Would love to hear your thoughts or see any pointers to obvious ways to handle this.
thank you!
fred
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 CSS 中定义一组样式名称,然后您可以使用一组样式名称为样式选择器控件提供值,如下所示:
I'd define a set of style names in CSS, then you can use a collection of style names to provide values for your style selector control, like so:
实现此目的的最佳方法是编译多个 CSS+Swf(assets) 文件,然后根据用户选择的内容在运行时加载它们。
这是迄今为止的最佳实践,我将它用于大型应用程序和小型应用程序,它比我能想到的所有其他解决方案都高。
祝你好运
The optimal way to achieve this is to compile several CSS+Swf(assets) files and then loading them at runtime according to what the user selected.
This is by far the best practice out there, I used it for large applications and small applications and it stands tall above every other solution I could think of.
good luck