This could be a depth and naming problem. U should use
mc.getNextHighestDepth() to determine the depth. And u also need to make
sure the instance name if unique for this component. Other thing is that
createTextField doesn't accept an init object. The colow does what u
want:


<?xml version="1.0" encoding="utf-8"?>

<mx:Application
    verticalGap="0"
    backgroundColor="#7D8FA8"
    xmlns:mx="http://www.macromedia.com/2003/mxml"; xmlns="*"
    pageTitle="Dingen"
        width="690" height="484">
        <mx:Script>
        <![CDATA[
                public function start()
                {
                        var x_num = my_mc.mouseX;
                        var y_num = my_mc.mouseY;
                        var depth_num = my_mc.getNextHighestDepth();
                        var name_str = "myOriginalInstanceName" +
depth_num;
                        
                        my_mc.createTextField(name_str, depth_num,
x_num, y_num, 10, 20);
                        var txt = my_mc[name_str];
                        txt.autoSize = "left";
                        txt.text = "great1!!";
                };
        ]]>
        </mx:Script>
        <mx:Canvas width="300" height="200" id="my_mc"
mouseDown="start()" backgroundColor="#3333FF"></mx:Canvas>
</mx:Application>
 

Greetz Erik

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of carmhuntress
Sent: donderdag 21 april 2005 7:14
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/
 



Reply via email to