0 Replies - 392 Views - Last Post: 05 September 2010 - 09:27 AM

#1 muimui14  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-September 10

How to adapt actionscript in this game?

Posted 05 September 2010 - 09:27 AM

Hey guys..Could you please help me to adapt this actionscript game? This game is a quiz,all questions are text,it will be random to ask player.. player have to type a text to answer..So the thing i would like to adapt is i want to change from text question to movieclip that it have to be random like text guestion.
this is actionscript that i would like to adapt :
Frame 1 :
stop();
var TOTAL_QUESTION:Number = 5;
var question:Array = new Array(TOTAL_QUESTION);
var choice:Array = new Array(TOTAL_QUESTION);
var poolQ:Array = new Array(TOTAL_QUESTION);
var i:Number;
var correctAns:Array;
var isCorrect:Boolean;
var selectQ:Array = new Array();
var userAns:Array = new Array();
var countQ:Number = 0;
var score:Number = 0;
var userName:String;
var keyObject:Object = new Object(); 
for (i = 0; i < TOTAL_QUESTION; i++) {
	poolQ[i] = i;
}

keyObject.onkeydown = checkEnter;
Selection.setFocus(nametext);
Selection.setSelection(0,nametext.length);
nametext.maxChars = 15;
Startgame_button.onRelease = function() {
	if (nametext.text.length > 0 && nametext.text != "Put your name in the box below") {
		userName = nametext.text;
		nextFrame();
	}
};

question[0] = "How many days in a week";
choice[0] = "7 days,7";

question[1] = "How many....?";
choice[1] = "10";

question[2] = "what's....?";     ====> here..How can i adapt it from text question to movieclip?
choice[2] = "cat";                     I tried to adapt by using Attactmovie / _root but movieclip just
                                       appeared but it wasn't been random like text question..
question[3] = "How many....?";
choice[3] = "30";

question[4] = "what's...?";
choice[4] = "rabbit";

function checkAnswer():Void {
	if (answertext.text.length > 1) {
		for (i = 0; i < correctAns.length; i++) {
			if (answertext.text == correctAns[i]) {
				isCorrect = true;
				score += 5;
				statustext.text = "Excellent" + userName;
				userAns.push(answertext.text);
				check_rf.gotoAndStop(2);
				_root.play();
			}
		}
		if (isCorrect == false) {
			score--;
			statustext.text = " " + userName + " wrong answer";
			answertext.text = ""; 
			check_rf.gotoAndStop(3);
		}
	} else {
		statustext.text = "please answer";
		check_rf.gotoAndStop(1);
	}
}
function checkEnter():Void {
	if(Key.getCode() == Key.ENTER) {
		checkAnswer();
	}
}

Frame 2:
isCorrect = false;
checkanswer.onRelease = checkAnswer;
Key.addListener(keyObject);
Selection.setFocus(answertext);
i = Math.floor(Math.random() * poolQ.length);
selectQ.push(poolQ[i]);
poolQ.splice(i,1);

question_pic.text = "Number" + selectQ[countQ] + " " + question[selectQ[countQ]];
correctAns = choice[selectQ[countQ]].split(",");
countQ++;



thank you so much in advance..
Actually im try to make a educational picture quiz..

Edited by macosxnerd101: Welcome to DIC! :) Please, :code:.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1