Try creating an mx.core.UITextField instead of a flash.display.TextField. UITextField implements the IUIComponent interface.

 

- Gordon

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of richmcgillicuddy
Sent: Monday, August 07, 2006 10:11 AM
To: [email protected]
Subject: [flexcoders] Simple TextField Question

 

I have a simple app that I want to have text show up using a TextField.

public function onTest() : void {
var myText:TextField = new TextField();
myText.x = 100;
myText.y = 100;
myText.width = 75;
myText.autoSize = TextFieldAutoSize.CENTER;
myText.height = 50;
myText.width = 200;
myText.backgroundColor = 0x849383;
myText.text = "Test Test Test Test Test Test";
var format1:TextFormat = new TextFormat();
format1.color = 0xFF0000;
myText.setTextFormat(format1);
addChild(myText);
}

I click on the button and get the error:

TypeError: Error #1034: Type Coercion failed: cannot convert
flash.text::TextField@11551769 to mx.core.IUIComponent.
at
mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()
at mx.core::Container/addChildAt()
at mx.core::Container/addChild()
at Step5/onTest()
at Step5/___Button1_click()

The addChild does not like that it is not a UIComponent. The addChild
works for text, Label and other UIComponents. I cannot get the
textField to show up. Eventually I want to have a component that
includes one or two text areas that are read only to the user, what is
the best way to do this?

Rich

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to