createTextField() is a low-level Flash method, not a Flex API, and TextField
isn't a Flex component. I'm not sure why it isn't showing up, but even if it
does, a TextField wouldn't participate in Flex measurement, focus
management, etc. Only a Flex component like Label or TextInput would "play
well" with the rest of Flex. So try code like
var label:Label = Label(canvasText.createChild(Label));
label.x = mouseX;
label.y = mouseY;
label.text = "this is a test";
in onMouseDownEvent().
- Gordon
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 20, 2005 10:14 PM
To: [email protected]
Subject: [flexcoders] Having trouble using createTextField
I am trying to create a textfield when you click inside a canvas at
the x and y coordinates and it continues not to work. My
understanding is that the canvas extends movieclip so I could add a
textfield to it. It would help to possibly get a better understanding
of how this all works.
Here is my code:
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
function onMouseDownEvent()
{
var point = {x:mouseX, y:mouseY};
canvasText.createTextField("mytext",0,point.x,point.y, 40, 40,
{text:'this is a test'});
};
]]>
</mx:Script>
<mx:Canvas id="canvasText" mouseDown="onMouseDownEvent();" width="300"
height="300"/>
</mx:Application>
I also cannot define properties when the app starts for instance
canvasText.mytext.border can not be defined in the function. I
modified this slightly and it work well in flash. Please help. Thanks.
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/