1
那么下面的代码有两个问题。帮助他们任何一个将不胜感激。as3代码中的简单问题,关于属性和变量
第一个问题是它不喜欢“(t.attribute == true)”。它似乎不像我这样使用变量。有什么方法可以解决这个问题吗?
第二个问题,是同样的变量,“(”un“+属性)”,我真的不知道如何正确地编码此位。
//这是什么调用它。
TextFormatCreator(bold, begin, end, tf);
//这是从问题的提取。标准是粗体/斜体/下划线。开始和结束是突出显示文本的参数。 tf是文本格式。
private var enbold:TextFormat = new TextFormat();
private var unbold:TextFormat = new TextFormat();
private var enitalic:TextFormat = new TextFormat();
private var unitalic:TextFormat = new TextFormat();
private var enunderline:TextFormat = new TextFormat();
private var ununderline:TextFormat = new TextFormat();
public function TextFormatCreator(attribute:String, begin:int, end:int, tf:JTextArea)
{
setBase()
begin=tf.getSelectionBeginIndex();
end=tf.getSelectionEndIndex();
var t:TextFormat=tf.getTextFormat(begin,end);
if (t.attribute==true) {
tf.setTextFormat(("un" + attribute), begin, end);
}
if (t.attribute==false) {
tf.setTextFormat(("en" + attribute), begin, end);
tf.setTextFormat(enbold, begin, end);
}
if (t.attribue==null) {
tf.setTextFormat(("en" + attribute), begin, end);
}
}
您是否使用'flash.text.TextFormat'类或自定义类,因为TextFormat中没有'attribute' – phwd 2010-06-23 14:53:31