View Full Version : Create TXT Input Field
PBKChris
12-11-2008, 04:56 PM
I am trying to create a input txt field to the stage by clicking a button and then clicking where I want it. I am not getting any errors but it does not do anything. Here is the code as I have it now.
import flash.text.TextField;
import flash.events.TextEvent;
var txt:TextField = new TextField();
textBox_btn.addEventListener(MouseEvent.MOUSE_DOWN , nowDrawText);
function nowDrawText(e:MouseEvent) {
var txt:TextField = new TextField();
txt.type = "input";
txt.text = "Enter your Text Here";
txt.textColor = 0xFFFFFF;
addChild(txt);
}
PBKChris
12-11-2008, 05:51 PM
Ok, I kind of figured it out but still does not do what I want. Here is the code.
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.TextEvent;
var txt:TextField = new TextField();
textBox_btn.addEventListener(MouseEvent.CLICK, nowDrawText);
function nowDrawText(e:MouseEvent) {
var mc:MovieClip = new MovieClip();
mc.buttonMode = true;
addChild( mc );
txt.type = "input";
txt.textColor = 0x000000;
txt.autoSize = "left";
txt.scaleY = 1;
txt.width = 10;
txt.height = 4;
txt.border = true;
txt.borderColor = 0x0000FF;
txt.text = "Enter Room Name";
txt.x = 20;
txt.y = 20;
mc.addChild(txt);
}
What I want it to do is when I click the button I want it to put the input text field where I click the second time. I have it to put it at 20px over and 20px down. I have no clue!!
dayana
12-15-2008, 06:59 AM
try this
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.TextEvent;
var txt:TextField = new TextField();
textBox_btn.addEventListener(MouseEvent.CLICK, nowDrawText);
function nowDrawText(e:MouseEvent) {
stage.addEventListener(MouseEvent.CLICK, addText);
}
function addText(evt:MouseEvent) {
var mc:MovieClip = new MovieClip();
mc.buttonMode = true;
addChild( mc );
txt.type = "input";
txt.textColor = 0x000000;
txt.autoSize = "left";
txt.scaleY = 1;
txt.width = 10;
txt.height = 4;
txt.border = true;
txt.borderColor = 0x0000FF;
txt.text = "Enter Room Name";
txt.x = stage.mouseX;
txt.y = stage.mouseY;
mc.addChild(txt);
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.