我使用flash文件作为测验游戏,基于AS2:
_root.next_btn.onPress = function() {
timings();
questno += 1;
import mx.transitions.*;
import mx.transitions.easing.*;
TransitionManager.start(_root.quest_txt, {type:Fade, direction:Transition.IN, duration:1.5, easing:None.easeNone});
_root.quest_txt.text = questions[questno-1];
_root.opt_a.text = opt_aval[questno-1];
_root.opt_b.text = opt_bval[questno-1];
_root.opt_c.text = opt_cval[questno-1];
_root.opt_d.text = opt_dval[questno-1];
_root.ans_txt.text = ans_txtval[questno-1];
_root.check_1.gotoAndStop(1);
_root.check_2.gotoAndStop(1);
_root.check_3.gotoAndStop(1);
_root.check_4.gotoAndStop(1);
_root.check_1.enabled = true;
_root.check_2.enabled = true;
_root.check_3.enabled = true;
_root.check_4.enabled = true;
_root.check_btn.enabled = true;
_root.wrong_mc._visible = false;
_root.right_mc._visible = false;
_root.next_btn._visible = false;
_root.correctansis._visible = false;
_root.correctans_txt._visible = false;
if (questno == questVal.length) {
this._visible = false;
}
_root.quest_no.text = questno;
};
我想替换这段代码
_root.next_btn.onPress = function() {
而不是按我想要用On Key Press替换它(例如键盘,当我点击" a")
您可以在此处找到该文件:http://www.ffiles.com/flash/web_applications_and_data/quiz_programme_2501.html
答案 0 :(得分:0)
在AS2中,您需要创建一个侦听器对象,将其附加到Key顶级类并触发您的函数。 AS2 Docs Reference Here。类似的东西:
var keyboardListener:Object = new Object();
keyboardListener.onKeyDown = function()
{
if(Key.getCode() == 65) //Keycode for a
{
//Run all the functionality you want here...
}
}
Key.addListener(keyboardListener:Object );