# Text Box Background

**URL:** <https://forum.kirupa.com/t/text-box-background/23569>\
**Category:** flash\
**Created:** [June 19, 2003, 5:32pm UTC](https://forum.kirupa.com/t/text-box-background/23569 "2003-06-19T17:32:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![turkey](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@turkey](https://forum.kirupa.com/u/turkey)\
**Post date:** [June 19, 2003, 5:32pm UTC](https://forum.kirupa.com/t/text-box-background/23569/1 "2003-06-19T17:32:27Z")

</div>

Is it possible to give the background of a dynamic text box alpha?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:01pm UTC](https://forum.kirupa.com/t/text-box-background/23569/2 "2003-06-19T19:01:36Z")

</div>

Yes it is possible.  
Check this example.  
😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:15pm UTC](https://forum.kirupa.com/t/text-box-background/23569/3 "2003-06-19T19:15:54Z")

</div>

claudio: That lowers the alpha of the entire background, sushis wanted just the background.

And if that is the case, no you can’t, unless you turn the border and background option off on the textbox and create a layer underneith it then draw your shape. You can then convert that into a movie clip and lower the alpha of that clip.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:21pm UTC](https://forum.kirupa.com/t/text-box-background/23569/4 "2003-06-19T19:21:09Z")

</div>

Oh yea, it applies to the border, text and bg.  
🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:38pm UTC](https://forum.kirupa.com/t/text-box-background/23569/5 "2003-06-19T19:38:07Z")

</div>

Hey lostinbeta, ive corrected the file so it only changes the bg alpha… thx  
🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 9:10pm UTC](https://forum.kirupa.com/t/text-box-background/23569/6 "2003-06-19T21:10:06Z")

</div>

Thanks claudio! Just what I was looking for…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 9:21pm UTC](https://forum.kirupa.com/t/text-box-background/23569/7 "2003-06-19T21:21:51Z")

</div>

You’re welcome 🙂  
Thx to lostinbeta for pointing my stupidit  
Sometimes i cant understand thigns very well hahaha 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 7:25am UTC](https://forum.kirupa.com/t/text-box-background/23569/8 "2003-06-20T07:25:52Z")

</div>

ok… i’m bored and i feel like writing something stupid. 😛

```auto
TextField.prototype.drawBackground = function() {
	if (!this.$bg) {
		this.$bg = this._parent.createEmptyMovieClip(this._name+"Bg", this.getDepth()-1);
	}
	this.$bg.clear();
	if (this.$background) {
		this.$bg.beginFill(this.$backgroundColor, this.$backgroundAlpha);
		this.$bg.moveTo(this._x, this._y);
		this.$bg.lineTo(this._x+this._width, this._y);
		this.$bg.lineTo(this._x+this._width, this._y+this._height);
		this.$bg.lineTo(this._x, this._y+this._height);
		this.$bg.lineTo(this._x, this._y);
		this.$bg.endFill();
	}
};
TextField.prototype.getBackground = function() {
	return this.$background;
};
TextField.prototype.setBackground = function(b) {
	this.$background = b;
	this.drawBackground();
};
TextField.prototype.getBackgroundColor = function() {
	return this.$backgroundColor;
};
TextField.prototype.setBackgroundColor = function(c) {
	this.$backgroundColor = c;
	this.drawBackground();
};
TextField.prototype.getBackgroundAlpha = function() {
	return this.$backgroundAlpha;
};
TextField.prototype.setBackgroundAlpha = function(a) {
	this.$backgroundAlpha = a;
	this.drawBackground();
};
TextField.prototype.addProperty("background", TextField.prototype.getBackground, TextField.prototype.setBackground);
TextField.prototype.addProperty("backgroundColor", TextField.prototype.getBackgroundColor, TextField.prototype.setBackgroundColor);
TextField.prototype.addProperty("backgroundAlpha", TextField.prototype.getBackgroundAlpha, TextField.prototype.setBackgroundAlpha);

```

a workaround to control the alpha value of the background by creating a movieclip in a lower depth than the textfield, and drawing the background of the textfield with the movieclip drawing methods.

there’s a stupid bug which i hope to fix tomorrow… it only works for textfield’s created in flash authoring, it won’t work if the textfield is created by the MovieClip.createTextField method.  
to be honest, i have no idea why it doesn’t work!! :-\

a quick example:

- create a textfield with the text tool and set its type to dynamic or input.
- give it an instance name, for the sake of the example, let’s call it myTextField.
- put this code in the frame actions of your movie:

```auto
myTextField.background = true;
myTextField.backgroundColor = 0xCC0000;
myTextField.backgroundAlpha = 40;

```

hope someone can get something useful out of this… 😛
