皆さん、こんにちは。
私は actionscript3 が初めてで、自分のコードでいくつかの問題を解決できません。最初の問題は、glowfilter が実行されていないことです。私の調査によると、glowfilter のアルファはそのように設定されていますが、正しい答えをクリックしても応答しません。しかし、試行アルゴリズムは正しいケースに入りません。2 番目の問題は、write answer をグローバルとして定義したいのですが、関数内で rightAnswer を変更しても変更されません。どうすればこの問題を解決できますか? actionscript でグローバル変数を定義するのは c とは違うと思います。
助けてくれてありがとう、そして私の悪い英語でごめんなさい!
<s:Button id="answer1" width="388" height="68" label="" cornerRadius="16"
fontFamily="Georgia" fontSize="17" click="checkanswers(1)">
<s:filters>
<mx:GlowFilter id="answer1_glow" color="0x00ff00" alpha="0" strength="3"/>
<mx:GlowFilter id="answer1_glow2" color="0xff0000" alpha="0" strength="3"/>
</s:filters>
</s:Button>
<s:Button id="answer2" width="388" height="68" label="" cornerRadius="16"
fontFamily="Georgia" fontSize="17" click="checkanswers(2)">
<s:filters>
<mx:GlowFilter id="answer2_glow" color="0x00ff00" alpha="0" strength="3"/>
<mx:GlowFilter id="answer2_glow2" color="0xff0000" alpha="0" strength="3"/>
</s:filters>
</s:Button>
<s:Button id="answer3" width="388" height="68" label="" cornerRadius="16"
fontFamily="Georgia" fontSize="17" click="checkanswers(3)">
<s:filters>
<mx:GlowFilter id="answer3_glow" color="0x00ff00" alpha="0" strength="3"/>
<mx:GlowFilter id="answer3_glow2" color="0xff0000" alpha="0" strength="3"/>
</s:filters>
</s:Button>
<s:Button id="answer4" width="388" height="68" label="" cornerRadius="16"
fontFamily="Georgia" fontSize="17" click="checkanswers(4)">
<s:filters>
<mx:GlowFilter id="answer4_glow" color="0x00ff00" alpha="0" strength="3"/>
<mx:GlowFilter id="answer4_glow2" color="0xff0000" alpha="0" strength="3"/>
</s:filters>
</s:Button>
</s:VGroup>
<fx:Script>
<![CDATA[
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
private var baseTimer:int;
private var t:Timer;
private const TIMER_INTERVAL:Number = 10;
public var rightAnswer:int = 0 ; // ---> ı want to use a global rightAnswer .
public function checkanswers(answer:int):void{
trace("answer is " + answer );
trace("rightanswer is " + rightAnswer);
if ( answer == rightAnswer) {
switch (answer) {
case 1 :
answer1.label = "green";
answer1.alpha = 1; // ı want to change glowfilters alpha in there.
break;
case 2 :
answer2.label = "green";
answer2_glow.alpha = 1;
break;
case 3 :
answer3.label = "green";
answer3_glow.alpha = 1;
break;
case 4 :
answer4.label = "green";
answer4_glow.alpha = 1;
break;
default :
break;
}
}
else{
switch (answer) {
case 1 :
answer1.label = "red";
answer1_glow2.alpha = 1;
break;
case 2 :
answer2.label = "red";
answer2_glow2.alpha = 1.0;
break;
case 3 :
answer3.label = "red;
answer3_glow2.alpha = 1.0;
break;
case 4 :
answer4.label = "red";
answer4_glow2.alpha = 1.0;
break;
default :
break;
}
switch (rightAnswer) {
case 1 :
answer1.label = "green";
answer1_glow.alpha = 1;
break;
case 2 :
answer2.label = "green";
answer2_glow.alpha = 1;
break;
case 3 :
answer3.label = "green";
answer3_glow.alpha = 1;
break;
case 4 :
answer4.label = "green";
answer4_glow.alpha = 1;
break;
default :
break;
}
}
}
public function application1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
soru.text = " En büyük kim ?";
answer1.label = "Galasaray";
answer2.label = "Bursaspor";
answer3.label = "Beşiktaş";
answer4.label = "Fenerbahçe";
var rightAnswer:int = 2;
trace(" rightAnswer fonkideki " + rightAnswer);
}
]]>
</fx:Script>