我正在使用动作脚本 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();