如何将 Spark 组件添加到 mx 扩展自定义 itemrenderer?
嘿大家,我 我已经在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样做你遇到什么问题?
在 createChildren() 内部,执行以下操作:
我从未使用 Spark TextArea 完成此操作,但我使用 BorderContainer 完成此操作,并且在大多数情况下效果良好。我无法让 BorderContainer 显示在 UIComponent 或 Container 上,但它在 Canvas 上运行良好。您可能会在使用 TextArea 时遇到类似的问题。
What problems are you having doing so?
Inside createChildren(), do this:
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.