使用什么作为自定义 MXML 组件的基础?

发布于 2024-12-01 16:39:24 字数 1554 浏览 1 评论 0原文

我在 Flex 4.5 应用程序中使用了多个自定义 MXML 组件。

它们都使用绝对坐标来放置图像、标签、线条等组件,并且当前基于 spark.components.BorderContainer

<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    width="160" height="140" borderWeight="0" 
    creationComplete="init(event)">

    <s:layout>
        <s:BasicLayout />
    </s:layout>

    <s:Image id="_avatar" x="0" y="0" width="160" height="120" />
    <s:Label id="_username" x="1" y="122" width="80" /> 
    <s:Label id="_bid" x="80" y="122" width="40" textAlign="center" /> 
    <s:Label id="_trix" x="120" y="122" width="36" textAlign="right" />
        .... and so on: Images, Labels, Paths, Lines, Rects .... 
</s:BorderContainer>

然后我意识到,我可能不必使用 BorderContainer,因为我不需要在我的周围绘制/需要任何边框风俗 成分。

但我不知道该用什么来代替。

我尝试采用; (并删除上面的标签),但随后我收到错误:

'Image' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.
'Label' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.

请问有什么建议吗?是否有一些最简单的火花“容器”?如果我使用(并且想要使用)绝对坐标,我是否需要一个“容器”?

I'm using several custom MXML components in my Flex 4.5 application.

They all use absolute coordinates to place Image, Label, Line, etc. components and are currently based on a spark.components.BorderContainer:

<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    width="160" height="140" borderWeight="0" 
    creationComplete="init(event)">

    <s:layout>
        <s:BasicLayout />
    </s:layout>

    <s:Image id="_avatar" x="0" y="0" width="160" height="120" />
    <s:Label id="_username" x="1" y="122" width="80" /> 
    <s:Label id="_bid" x="80" y="122" width="40" textAlign="center" /> 
    <s:Label id="_trix" x="120" y="122" width="36" textAlign="right" />
        .... and so on: Images, Labels, Paths, Lines, Rects .... 
</s:BorderContainer>

Then I've realized, that I probably don't have to use BorderContainer, because I don't draw/need any borders around my custom components.

But I don't know, what to take instead of it.

I've tried taking <mx:UIComponent> (and removing <s:Layout> tag above), but then I get the error:

'Image' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.
'Label' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.

Any suggestions please? Is there some simplest possible spark "container"? And do I need a "container" at all if I use (and want to use) absolute coordinates?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与酒说心事 2024-12-08 16:39:24

我建议您使用s:Group。只要 BasicLayout 是默认布局,您就可以省略 layout 声明。

UIComponent 不是容器,因此它没有默认占位符供子级使用 MXML 添加它们。

I recommend you to use s:Group. And you can omit layout declaration as far as BasicLayout is default layout.

UIComponent isn't container so it hasn't default placeholder for children to add them with MXML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文