Is it possible to give the background of a dynamic text box alpha?
Yes it is possible.
Check this example.
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.
Oh yea, it applies to the border, text and bg.
Hey lostinbeta, ive corrected the file so it only changes the bg alpha… thx
Thanks claudio! Just what I was looking for…
You’re welcome
Thx to lostinbeta for pointing my stupidit
Sometimes i cant understand thigns very well hahaha
ok… i’m bored and i feel like writing something stupid.
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:
myTextField.background = true;
myTextField.backgroundColor = 0xCC0000;
myTextField.backgroundAlpha = 40;
hope someone can get something useful out of this…