Flex 4 重用对话框布局
我刚刚在 Flex 应用程序中创建了数十个弹出对话框中的第一个,并想知道重用布局的最佳方法是什么,这样我就不必在每个表单中重复它。我尝试制作自定义 MXML 组件,但是当我继承它时,我无法添加子控件。我不确定 CSS 是否可以处理它......或者如何处理。答案是皮肤吗?
下面是对话框的内容,它只是一个可调整大小的 TitleWindow:
<components:layout>
<s:BasicLayout />
</components:layout>
<!-- Content -->
<s:SkinnableContainer id="content" top="8" left="8" bottom="{buttonGroup.height + 16}" right="8" >
....content here....
</s:SkinnableContainer>
<!-- Buttons -->
<s:HGroup id="buttonGroup" left="8" bottom="8" right="8">
... buttons here...
</s:HGroup>
正如您所看到的,必须在整个地方复制该布局真的很糟糕!
I've just create the first of dozens of pop-up dialogs in my Flex application and wondering what is the best way to reuse the layout so I don't have to duplicate it in every form. I tried making a custom MXML component but when I inherited from it, I couldn't add child controls. I'm not sure if CSS can handle it...or how. Is the answer a skin?
Here is the contents of the dialog which is just a resizeable TitleWindow:
<components:layout>
<s:BasicLayout />
</components:layout>
<!-- Content -->
<s:SkinnableContainer id="content" top="8" left="8" bottom="{buttonGroup.height + 16}" right="8" >
....content here....
</s:SkinnableContainer>
<!-- Buttons -->
<s:HGroup id="buttonGroup" left="8" bottom="8" right="8">
... buttons here...
</s:HGroup>
As you can see, it would really stink to have to duplicate that layout all over the place!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以建议您采取一些不同的实现方式吗:
然后在 CSS 中您应该使用一些高级选择器,并且您将为所有填充提供一个中心位置:
检查 包含工作示例的 ZIP 我已上传到我的域!
Can I suggest you a bit different implementation:
And then in your CSS you should use some of the advanced selectors and you'll have a central place for all of the paddings:
Check the ZIP with the working sample I uploaded to my domain!
编辑:如果您需要在运行时设置“内容”部分和“按钮”部分,并且仍然能够在 MXML 中使用自定义组件......好吧,我怀疑这是可能的。如果放弃 MXML,则必须为组件创建一些配置对象并将其传递给构造函数,并且还需要在自定义组件中重写方法 createChildren。
如果“按钮”部分是静态的 - 请阅读下面的文本。
您可以尝试为该组件创建一个自定义 SkinnableComponent 和一个外观类,您将在其中放置布局。
1) 从 SkinnableComponent 扩展,如下所示
2) 为您的组件创建皮肤(Flash Builder 非常有用)[例如]
请注意 id="contentGroup" 而不是 id="content" 不只是这样,contentGroup 是一个静态每个皮肤中放置子元素的部分。
EDIT: If you need to set up "content" part and "buttons" part at runtime and still be able to use your custom component in MXML... well, I doubt it's possible. If you abandon MXML you have to create some configurational object for your component and pass it to the constructor, and also you need overriden method createChildren in your custom component.
If "buttons" part is static - read below text.
You could try to create a custom SkinnableComponent and a skin class for this component where you will place your layout.
1) Extend from the SkinnableComponent, like this
2) Create skin for you component (Flash Builder very usefull) [for example]
Notice that id="contentGroup" instead of id="content" is not just like that, contentGroup is a static part of every skin where child elements are placed.