# Text box help

**URL:** <https://forum.kirupa.com/t/text-box-help/261487>\
**Category:** flash\
**Created:** [May 28, 2008, 5:00am UTC](https://forum.kirupa.com/t/text-box-help/261487 "2008-05-28T05:00:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spartan\_301](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Spartan\_301](https://forum.kirupa.com/u/Spartan_301)\
**Post date:** [May 28, 2008, 5:00am UTC](https://forum.kirupa.com/t/text-box-help/261487/1 "2008-05-28T05:00:16Z")

</div>

Hello all! I’ve searched the forums but apparently I’m not searching for the right thing so I’ll describe what I want to do and someone more smart than I (shouldn’t take much) can tell me what I SHOULD be looking for…

I’ve got 3 buttons on the bottom of a 640x400 canvas. As the user places the mouse over each button, I want a 340x200 text box to come up in the middle of the screen (or slightly below middle) to display text. I was able to achieve this by using the “over” frame of the button’s design properties but the windows become visible when I place my mouse cursor over the middle of the screen where the windows appear when the mouse is over the actual button.

Help!

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [May 28, 2008, 7:16pm UTC](https://forum.kirupa.com/t/text-box-help/261487/2 "2008-05-28T19:16:19Z")

</div>

Hundreds of ways of doing this, hopefully this will help you understand an AS approach.

Place 3 buttons on your stage and name then btn1, btn2, btn3. Then paste this code into your main timeline

```auto

function showText (e:String) {
	_root.createTextField ("myText",this.getNextHighestDepth (),(640 - 200) / 2,(400 - 30) / 2,200,30);
	var my_fmt:TextFormat = new TextFormat ();
	my_fmt.bold = true;
	my_fmt.font = "Arial";
	my_fmt.color = 0xFF9900;
	myText.wordWrap = true;
	myText.multiline = true;
	myText.border = true;
	myText.type = "dynamic";
	myText.autoSize = false;
	myText.setNewTextFormat (my_fmt);
	myText.text = e;
}
btn1.onRollOver = function () {
	showText ("Button 1 text");
};
btn2.onRollOver = function () {
	showText ("Button 2 text");
};
btn3.onRollOver = function () {
	showText ("Button 3 text");
};
btn1.onRollOut = function () {
	myText.removeTextField ();
};
btn2.onRollOut = function () {
	myText.removeTextField ();
};
btn3.onRollOut = function () {
	myText.removeTextField ();
};

```

---

<div class="post-metadata">

**Author:** ![Spartan\_301](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Spartan\_301](https://forum.kirupa.com/u/Spartan_301)\
**Post date:** [May 29, 2008, 1:02am UTC](https://forum.kirupa.com/t/text-box-help/261487/3 "2008-05-29T01:02:51Z")

</div>

That’s freaking awesome! Only thing I needed to do was change the autosize to true and it works great!

2 more questions…

1. Can the box be filled with #333333 or #666666?

2. Can line breaks be inserted into each text section? ie…

```auto
Comments? Questions? Contact us at [EMAIL="jibberjabber@somewhere.net"]jibberjabber@somewhere.net[/EMAIL]
 
You can also contact us at 800-123-4567

```

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [May 29, 2008, 2:33pm UTC](https://forum.kirupa.com/t/text-box-help/261487/4 "2008-05-29T14:33:43Z")

</div>

Sure. Just use the background color property and use html text

```auto

function showText (e:String) {
	_root.createTextField ("myText",this.getNextHighestDepth (),(640 - 200) / 2,(400 - 30) / 2,200,30);
	myText.background = true;
	myText.backgroundColor = 0x666666;
	var my_fmt:TextFormat = new TextFormat ();
	my_fmt.bold = true;
	my_fmt.font = "Arial";
	my_fmt.color = 0xFF9900;
	myText.wordWrap = true;
	myText.multiline = true;
	myText.border = true;
	myText.type = "dynamic";
	myText.autoSize = true;
	myText.html = true;
	myText.setNewTextFormat (my_fmt);
	myText.htmlText = e;
}
btn1.onRollOver = function () {
	showText ("Button 1 text <br> something else here");
};
btn2.onRollOver = function () {
	showText ("Button 2 text");
};
btn3.onRollOver = function () {
	showText ("Button 3 text");
};
btn1.onRollOut = function () {
	myText.removeTextField ();
};
btn2.onRollOut = function () {
	myText.removeTextField ();
};
btn3.onRollOut = function () {
	myText.removeTextField ();
};

```

Should do the trick.

---

<div class="post-metadata">

**Author:** ![Spartan\_301](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Spartan\_301](https://forum.kirupa.com/u/Spartan_301)\
**Post date:** [May 29, 2008, 4:45pm UTC](https://forum.kirupa.com/t/text-box-help/261487/5 "2008-05-29T16:45:07Z")

</div>

Very nice. The background worked great but I think that it doesn’t recognize the \<br\> as code rather than just text. It just shows the \<br\> tag in the text.

btw, thanks for all the help man!

---

<div class="post-metadata">

**Author:** ![swasgrafx](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@swasgrafx](https://forum.kirupa.com/u/swasgrafx)\
**Post date:** [June 3, 2008, 10:39pm UTC](https://forum.kirupa.com/t/text-box-help/261487/6 "2008-06-03T22:39:04Z")

</div>

Great tutorial and help. Is there a way to Pass the text as a Variable to a web page with getURL call? Attempting to pass the myText a string in ASP. Thanks

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 3, 2008, 11:42pm UTC](https://forum.kirupa.com/t/text-box-help/261487/7 "2008-06-03T23:42:39Z")

</div>

I wouldn’t use getURL, I would use Load Vars(). Then send as a form value to ASP.

```auto

myData = new Load Vars();
myData.myText = _root.myText.text;
myData.send("yourasp.asp",myData, "POST");

```

Then is your asp just do something like

```auto

<% myText = Request.Form("myText") %>

```

That’s not tested or anything but it’s the basic idea.

---

<div class="post-metadata">

**Author:** ![swasgrafx](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@swasgrafx](https://forum.kirupa.com/u/swasgrafx)\
**Post date:** [June 4, 2008, 12:02am UTC](https://forum.kirupa.com/t/text-box-help/261487/8 "2008-06-04T00:02:54Z")

</div>

Forgive me as I’m still trying to catch up to you all in knowledge and experience;  
Here’s what I have. Flash working but not passing to ASP;

stop();

function showText (e:String) {  
\_root.createTextField (“myText”,this.getNextHighestDepth (),(400 - 40) / 2,(100 - 30) / 2,200,30);  
var my\_fmt:TextFormat = new TextFormat ();  
my\_fmt.bold = true;  
my\_fmt.font = “Arial”;  
my\_fmt.color = 0xFF9900;  
myText.wordWrap = true;  
myText.multiline = true;  
myText.border = false;  
myText.type = “dynamic”;  
myText.autoSize = false;  
myText.setNewTextFormat (my\_fmt);  
myText.text = e;  
}

btn1.onPress = function () {  
showText (“Part1”);  
};  
btn2.onPress = function () {  
showText (“Part2”);  
};  
btn3.onPress = function () {  
showText (“Part3”);  
};

send\_btn.onRelease = function() {   
myData = new Load Vars();  
myData.myText = \_root.myText.text;  
myData.send(“cart.asp”,myData, “POST”);

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 4, 2008, 1:15am UTC](https://forum.kirupa.com/t/text-box-help/261487/9 "2008-06-04T01:15:08Z")

</div>

Ha, I’m sorry no space between LoadVars();

```auto

stop();

function showText(e:String) {
	_root.createTextField("myText",this.getNextHighestDepth(),(400-40)/2,(100-30)/2,200,30);
	var my_fmt:TextFormat = new TextFormat();
	my_fmt.bold = true;
	my_fmt.font = "Arial";
	my_fmt.color = 0xFF9900;
	myText.wordWrap = true;
	myText.multiline = true;
	myText.border = false;
	myText.type = "dynamic";
	myText.autoSize = false;
	myText.setNewTextFormat(my_fmt);
	myText.text = e;
}

btn1.onPress = function() {
	showText("Part1");
};
btn2.onPress = function() {
	showText("Part2");
};
btn3.onPress = function() {
	showText("Part3");
};

send_btn.onRelease = function() {
	myData = new LoadVars();
	myData.myText = _root.myText.text;
	myData.send("cart.asp",myData,"POST");
};

```

That should work.

---

<div class="post-metadata">

**Author:** ![swasgrafx](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@swasgrafx](https://forum.kirupa.com/u/swasgrafx)\
**Post date:** [June 5, 2008, 2:53pm UTC](https://forum.kirupa.com/t/text-box-help/261487/10 "2008-06-05T14:53:37Z")

</div>

OK. Thanks for the LoadVars Fix… I’m understanding more of these functions, but still can’t seem to send any of the Vars successfully. I have tried the following ASP scripts with the following results;

Flash Code “POST”:  
send\_btn.onRelease = function() {  
myData = new LoadVars();  
myData.myText = \_root.myText.text;  
myData.send(“cart.asp”,myData,“POST”);  
};

ASP Code:  
\<% showText = Request.Form(“myText”) %\>

Browser Yields Blank Page With URL Reading;  
[http://www.websitename.com/cart.asp](http://www.websitename.com/cart.asp)

* * *

Flash Code “GET”:  
send\_btn.onRelease = function() {  
myData = new LoadVars();  
myData.showText = \_root.createTextField;  
if(my\_fmt:TextFormat = new TextFormat ());  
myData.send(“cart.asp”,myData,“GET”);  
};

ASP Code:  
\<% showText = Request.QueryString(“myText”) %\>

Browser Yields Blank Page With URL Reading;  
[http://www.websitename.com/cart.asp?showText=[type%20Function]](http://www.websitename.com/cart.asp?showText=%5Btype%20Function%5D)

If flash is sending Vars successfully to the ASP page shouldn’t we be seeing something like myData=Part1,Part2,Part3

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 5, 2008, 3:41pm UTC](https://forum.kirupa.com/t/text-box-help/261487/11 "2008-06-05T15:41:16Z")

</div>

Pm me the public URL to addCart.asp and I will try and hook it up… Just do a response.write so i can see the result…

---

<div class="post-metadata">

**Author:** ![swasgrafx](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@swasgrafx](https://forum.kirupa.com/u/swasgrafx)\
**Post date:** [June 11, 2008, 4:05pm UTC](https://forum.kirupa.com/t/text-box-help/261487/12 "2008-06-11T16:05:25Z")

</div>

Thanks Digitalosophy. Finally figured it out… now attempting to do multiple submissions. Will post successful code when complete.
