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