如何将 Spark 组件添加到 mx 扩展自定义 itemrenderer?

发布于 2024-10-02 12:55:16 字数 1369 浏览 4 评论 0原文

嘿大家,我 我已经在 Air 应用程序上工作了一段时间,在我的一个 mx:lists 中,我有一个用纯 AS(无 mxml)编写的自定义渲染器。 它扩展了 listitemrenderer mx 组件。 在其中我重写了 createChildren() 函数来添加我自己的一些子项。

现在,我想在这个 itemrenderer 中添加一个从右到左的文本,我想在这个 createChildren() 函数中添加一个 Spark:TextArea 组件,

有没有办法做到这一点?

这是 itemRenderer:

import flash.text.TextField;

import mx.controls.listClasses.ListItemRenderer;

import spark.components.TextArea;

public class MySumTileIR2 extends ListItemRenderer
{
    public function MySumTileIR2()
    {
        super();
    }

    override protected function createChildren():void {
        super.createChildren();
        label.visible = false;

        var tf:TextField = new TextField();
        tf.text = "this is a TextField";
        this.addChild(tf);
        var ta:TextArea = new TextArea();
        ta.text = "this is a Spark TextArea"; 
        this.addChild(ta);
    }
}

这是它的所有者:

<mx:Panel id="MTGpicsPanel" label="totalPics" title="{totalPics}" height="100%" horizontalAlign="right">
   <mx:List width="100%" top="18" bottom="18" left="18" right="18" id="MTGpicsList" x="0"y="0" height="100%" variableRowHeight="true" editable="false" dataProvider="{chosenPics}"  doubleClick="gotoPic();" doubleClickEnabled="true" itemRenderer="MySumTileIR2"/>
</mx:Panel>

运行这个我看到文本字段,但看不到文本区域

hey all, i
have been working on an air app for quite some time and in one of my mx:lists i have a custom renderer written in pure AS (no mxml).
it extends the listitemrenderer mx componenet.
in it i have overrode the createChildren() function to add some children of my own.

now, fort right-to-left text i want in this itemrenderer, i would like to add a spark:TextArea component in this createChildren() function

is there a way to do so?

this is the itemRenderer:

import flash.text.TextField;

import mx.controls.listClasses.ListItemRenderer;

import spark.components.TextArea;

public class MySumTileIR2 extends ListItemRenderer
{
    public function MySumTileIR2()
    {
        super();
    }

    override protected function createChildren():void {
        super.createChildren();
        label.visible = false;

        var tf:TextField = new TextField();
        tf.text = "this is a TextField";
        this.addChild(tf);
        var ta:TextArea = new TextArea();
        ta.text = "this is a Spark TextArea"; 
        this.addChild(ta);
    }
}

and this is it's owner:

<mx:Panel id="MTGpicsPanel" label="totalPics" title="{totalPics}" height="100%" horizontalAlign="right">
   <mx:List width="100%" top="18" bottom="18" left="18" right="18" id="MTGpicsList" x="0"y="0" height="100%" variableRowHeight="true" editable="false" dataProvider="{chosenPics}"  doubleClick="gotoPic();" doubleClickEnabled="true" itemRenderer="MySumTileIR2"/>
</mx:Panel>

running this i see the textfield but not the textarea

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

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

发布评论

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

评论(1

一曲爱恨情仇 2024-10-09 12:55:16

这样做你遇到什么问题?

在 createChildren() 内部,执行以下操作:

var ta : spark.components.TextArea = new TextArea();
this.addChild(ta);

我从未使用 Spark TextArea 完成此操作,但我使用 BorderContainer 完成此操作,并且在大多数情况下效果良好。我无法让 BorderContainer 显示在 UIComponent 或 Container 上,但它在 Canvas 上运行良好。您可能会在使用 TextArea 时遇到类似的问题。

What problems are you having doing so?

Inside createChildren(), do this:

var ta : spark.components.TextArea = new TextArea();
this.addChild(ta);

I've never done it w/ a Spark TextArea, but I have done it with a BorderContainer and it worked well, for the most part. I couldn't get BorderContainer to show up on a UIComponent or Container, but it worked fine on a Canvas. You may run into similar issues w/ a TextArea.

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