---
title: "Flash - textarea组件的背景边框设置 "
author: "guobinperfect"
date: "2012-04-27T08:31:30Z"
tags: []
categories: ["Web前端"]
slug: "flash-textarea"
draft: false
lastmod: "2012-04-27T08:49:32Z"
id: 1500338
url: "https://guobinperfect.iteye.com/blog/1500338"
---

**as2中的办法：**
TestArea组件背景透明，边框也透明。 
myTextArea.depthChild0._visible = false; 
TestArea组件背景透明，边框不透明。 
_global.styles.TextArea.backgroundColor = undefined; 
TestArea组件背景和边框的透明度。 
myTextArea.depthChild0._alpha = 0; 


TestArea组件背景颜色。 
_global.styles.TextArea.backgroundColor = 0xff0000; 

TestArea组件边框颜色。 
myTextArea.setStyle("borderColor","0xff0000");//下 
myTextArea.setStyle("highlightColor","0xff0000");//上 
myTextArea.setStyle("color","0xff0000");//字 
myTextArea.setStyle("shadowColor","0xff0000");//下 
myTextArea.setStyle("borderCapColor","0xff0000");//左右外 
myTextArea.setStyle("shadowCapColor","0xff0000");//左右内 
myTextArea.setStyle("buttonColor", "0xffffff"); //顶部   （PS:这个是我补充的)


如下是我做过的设置
function cssInit(myTextArea:mx.controls.TextArea) { 
myTextArea.enabled = false;   //让文字不可选 
myTextArea.setStyle("backgroundColor", "0xffffff"); 
myTextArea.setStyle("fontSize", "12"); 
myTextArea.setStyle("fontFamily", "宋体"); 

//下发代码是让TextArea的边框不显示 
myTextArea.setStyle("borderColor", "0xffffff"); 
//下 
myTextArea.setStyle("highlightColor", "0xffffff"); 
//上 
myTextArea.setStyle("color", "0x333333"); 
//字 
myTextArea.setStyle("shadowColor", "0xffffff"); 
//下 
myTextArea.setStyle("borderCapColor", "0xffffff"); 
//左右外 
myTextArea.setStyle("shadowCapColor", "0xffffff"); 
//左右内 
myTextArea.setStyle("buttonColor", "0xffffff"); 
//top 
}

如何既不显示边框也不显示背景，以及修改disabledColor
var myTextArea = textinfo;
myTextArea.text = "士大夫士大夫十分!";
myTextArea.vScrollPolicy = "off";
myTextArea.hScrollPolicy = "off";
myTextArea.depthChild0._visible = false;//设置背景和边框为透明
//myTextArea.html = true;
//myTextArea.text = "<font size='14' color='0xffffff'>商品房商品住宅<br/>量减价升!</font>";
myTextArea.enabled = false;
myTextArea.setStyle("disabledColor", "0xffffff");
myTextArea.setStyle("fontSize", "14");
myTextArea.setStyle("fontFamily", "黑体");
myTextArea.setStyle("color", "0xffffff");
myTextArea.setStyle("fontWeight", "bold"); 


**as3中的办法：**
cs5中，TextArea是没法像as2中直接设置样式的，可以用一个变态的方法给其里面的textfiled设置一个背景

1.var tmf:TextFormat = new TextFormat  ;
2.tmf.color = 0xffffff;
3.textArea.setStyle("textFormat",tmf);
4.var txt:TextField = textArea.getChildAt(0) as TextField;
5.txt.background = true;
6.txt.backgroundColor = 0x00;