How about:
var txt: UITextField = new UITextField();
Cheers,
Simon
On 15 Jul 2008, at 19:15, Maciek Sakrejda wrote:
>What am I doing wrong???
Well, for one thing, you are not including the error you get.
But I think I can be more helpful anyway. Even though
Container.addChild() (inherited by Application.addChild(), which you are
calling) takes a DisplayObject, it needs a IUIComponent. From the Flex
docs
( http://livedocs.adobe.com/flex/201/langref/mx/core/Container.html#addChild()
):
Note: While the child argument to the method is specified as of type
DisplayObject, the argument must implement the IUIComponent interface to
be added as a child of a container. All Flex components implement this
interface.
TextField is a Flash (and not Flex) component, so it does not implement
IUIComponent. You can use a TextInput instead.
--
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com
-----Original Message-----
From: timgerr <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: [flexcoders] Add ActionScript created items to flex
Date: Tue, 15 Jul 2008 16:30:37 -0000
I think this is an easy one but I cannot figure it out. I want to
dynamically crate a text imput box via ActionScript and I get errors
when I do the addChild. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import flash.text.*;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
public function WriteMe():void
{
var field:TextField = new TextField();
field.type = TextFieldType.INPUT;
field.border = true;
field.background = true;
addChild(field);
}
]]>
</mx:Script>
<mx:Button id="btn" label="press me" click="WriteMe()"/>
</mx:Application>
I am getting a debug error with the addChild(field);
What am I doing wrong???
Thanks for the read and help,
timgerr