LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 


Prev Previous Post   Next Post Next
  #1  
Old 01-26-2007, 07:02 PM
chosen chosen is offline
Registered User
 
Join Date: Jul 2006
Posts: 23
Rep Power: 0
chosen is on a distinguished road
Source class file

Hello I need some assistance with my class file. What I am doing is I have a quiz with different subjects in a combo box that the user can select (Math, chemistry, social studies..). What I want is to attach a separate class fiel for each subject that will display the problem and check the users anwer. Here is what I have so far, but its not working properly. My questions work fine within flash but when I use the class file it doesn't function. Thanks for your help.


Actionscript:
//This what I have modified to try to make it work in .as file
//Class Math ()
//This is variable set up to get the users infor
var youranswer:String;
function Math()
{
}
//This displays the question
private function displayequation()
{
	var myEquations:Array = [];
	var myOperators:Array = ["+", "-", "*", "/"];
	for (var i:Number = 0; i < 10; i++)
	{
		var num1:Number = Math.round((Math.random() * 50) + 1);
		var num2:Number = Math.round((Math.random() * 50) + 1);
		var randOp:Number = Math.round(Math.random() * (myOperators.length - 1));
		var temp:String = num1.toString() + " " + myOperators[randOp] + " " + num2.toString();
		//var temp:String = num1.toString() + myOperators[randOp] + num2.toString();
		trace("this is random string " + i + ": " + temp);
		myEquations.push(temp);
	}
	var currentEq:Number = 0;
	var setEquation:Function = function ()
	{
		eq_txt.text = myEquations[currentEq];
	};
	var checkFunction:Function = function ()
	{
		var ta:Array = myEquations[currentEq].split("");
		trace("here's ta: " + ta);
		var tmp:Number;
		switch (ta[1])
		{
		case "+" :
			trace("we're adding");
			tmp = parseInt(ta[0]) + parseInt(ta[2]);
			break;
		case "-" :
			trace("we're subtrating");
			tmp = parseInt(ta[0]) + parseInt(ta[2]);
			break;
		case "*" :
			trace("we're multiplying");
			tmp = parseInt(ta[0]) + parseInt(ta[2]);
			break;
		case "/" :
			trace("we're dividing");
			tmp = parseInt(ta[0]) + parseInt(ta[2]);
			break;
		}
		trace("and tmp is: " + tmp);
		if (tmp.toString() == ans_txt.text)
		{
			trace("Correct!");
			ans_txt.text = "";
			currentEq++;
			setEquation();
		}
		else
		{
			trace("wrong!");
		}
	};
}
setEquation();
check_mc.onRelease = checkFunction;

Last edited by Scottae : 01-26-2007 at 07:23 PM Reason: Format with AS tags
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Class file not updating skitzer Flash CS 5.5 14 11-29-2011 04:29 AM
Intervals within an .as class file drgonjo Flash MX 2004 3 10-17-2006 04:20 AM
A useful tips about how to extract .swf file from a PowerPoint file susanzheng General Flash 0 11-02-2005 07:56 AM
external class in .as file disbot4 Flash MX 2004 4 04-20-2005 01:03 PM
Dynamically load .swf file and register class Osh_it Actionscript 2.0 1 01-18-2005 04:44 PM




All times are GMT. The time now is 06:42 PM.