Copy link to clipboard
Copied
I am using an event handler to listen for MOUSE_UP on stage_mc to let the user create text and images on the screen. I have buttons above the stage that set a variable, then the variable determines which action occurs with the mouse event.
I would like the user to be able to enter text, and can create an input text field on the stage, but the user then has to click inside the text field to begin typing. Because of the event handler, this 2nd MOUSE_UP repositions the text field, although it IS successful in setting the focus.
Ideally, I would like for the user to be able to create the input text field by clicking on the stage and then begin typing without having to click a 2nd time. It seems simple enough, but I still don't understand OOP enough to decipher the help pages available within the program.
Does anyone have any suggestions? Here is my code (some of the included variable are set in previous lines):
//Setting up the Text Field parameters
var outputText:TextField = new TextField();
var textFormat:TextFormat = new TextFormat();
// Enabling the input tools
function startDraw(event:MouseEvent):void {
if (currentTool.name == "lineTool_mc") {
newLine.graphics.moveTo(event.localX, event.localY);
stage_mc.addEventListener(MouseEvent.MOUSE_MOVE, drawLine);
} else if (currentTool.name == "textTool_mc") {
textFormat.color = 0x336699;
textFormat.size = 48;
textFormat.font = "Times";
outputText.defaultTextFormat = textFormat;
outputText.selectable = true;
outputText.x = event.localX;
outputText.y = event.localY;
outputText.background = false;
outputText.border = true;
outputText.autoSize = TextFieldAutoSize.LEFT;
outputText.type = TextFieldType.INPUT;
designContainer.addChild(outputText);
} else if (currentTool.name == "brushTool_mc") { ...
1 Correct answer
on mouseup or click, if the mouse is down, you can use:
stage.focus=outputText;
if the mouse isn't down, you can don't need a listener to trigger the above.
Copy link to clipboard
Copied
on mouseup or click, if the mouse is down, you can use:
stage.focus=outputText;
if the mouse isn't down, you can don't need a listener to trigger the above.
Copy link to clipboard
Copied
That was too easy. I just don't get it yet. Maybe after a year of these stupid questions OOP will start to make sense to me.
Thanks again.
Copy link to clipboard
Copied
you're welcome.

