开发者

What to use as base for a custom MXML component?

开发者 https://www.devze.com 2023-03-31 04:08 出处:网络
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.Bord

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 impl开发者_如何转开发ement '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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号