我使用動作腳本3在Flash中進行測驗。下面的代碼使文本變得更小,如果它超過2行,以便它可以放在問題框中。這工作!但是,當您更改關鍵幀時,該框的格式會發生變化。例如,當問題出現時,字體會發生變化,但當您回答問題和關鍵幀更改時,字體會發生變化,使其溢出邊緣。如何通過關鍵幀繼續格式化盒子
如何使關鍵幀的格式化繼續進行。
這是遊戲的動作。
var smallLimit:int = 1;
var format:TextFormat = new TextFormat();
myTextField11.text = shuffledAnswers1[0]; //puts into the text boxes the random answers
myTextField21.text = shuffledAnswers1[1];
myTextField31.text = shuffledAnswers1[2];
myTextField41.text = shuffledAnswers1[3];
var testSize11:int = 25;
var testSize21:int = 25;
var testSize31:int = 25;
var testSize41:int = 25;
while(testSize11 > smallLimit){
updateFormat11(testSize11);
trace(myTextField11.numLines );
if(myTextField11.numLines > 1){
testSize11--;
}else{
testSize11 = smallLimit;
}
}
while(testSize21 > smallLimit){
updateFormat21(testSize21);
trace(myTextField21.numLines );
if(myTextField21.numLines > 1){
testSize21--;
}else{
testSize21 = smallLimit;
}
}
while(testSize31 > smallLimit){
updateFormat31(testSize31);
trace(myTextField31.numLines );
if(myTextField31.numLines > 1){
testSize31--;
}else{
testSize31 = smallLimit;
}
}
while(testSize41 > smallLimit){
updateFormat41(testSize41);
trace(myTextField41.numLines );
if(myTextField41.numLines > 1){
testSize41--;
}else{
testSize41 = smallLimit;
}
}
function updateFormat11(size11:int):void{
format.size = size11;
myTextField11.setTextFormat(format);
}
function updateFormat21(size21:int):void{
format.size = size21;
myTextField21.setTextFormat(format);
}
function updateFormat31(size31:int):void{
format.size = size31;
myTextField31.setTextFormat(format);
}
function updateFormat41(size41:int):void{
format.size = size41;
myTextField41.setTextFormat(format);
}
這是關鍵幀2,它在文本框中設置問題。
myTextField11.text = shuffledAnswers1[0];
myTextField21.text = shuffledAnswers1[1];
myTextField31.text = shuffledAnswers1[2];
myTextField41.text = shuffledAnswers1[3];
stop();
我會爲你寫一個例子。 –