Calling a method in another class
I am new to AS3. I am creating a series of Flash Activities for an educational website and would like to put common function into their own class. I am not sure how to do that. What is have tried is:
1. Import the class( import MMESCommon;)
2. creating a new variable/object(var MMES:Object = new MMESCommon;)
3. Calling a function in the class(MMES.LetterScore(95);)
This process( or one very similar) has worked for me in other languages. However, here I am getting the error:
ReferenceError: Error #1069: Property LetterScore not found on MMESCommon and there is no default value.
at AdditionLevel01/DrawGameFrame()
at AdditionLevel01/checkanswer()
I know LetterScore exists. here in the MMES Class:
Code:
/**
* Mrs. Marker's Education Site Common Flash funcions
* This file contains the action script for the MMES Common class.
* AS3
* MMES(tm) : Mrs. Marker's Educational Site (http://mrsmarker.dyndns.org)
* Copyright 2012, Mrs. Marker's Educational Site (http://mrsmarker.dyndns.org)
* @copyright Mrs. Marker's Eduational Site (http://mrsmarker.dyndns.org)
* @link http://mrsmarker.dyndns.org MMES(tm)
* @package MMESCommon
* @license Propietary, All Rights Reserved
*/
package {
/**
* Global import commands
*/
import flash.display.*;
import flash.events.*;
/**
* MMESCommon Class definition
* This class contains methods used by some/all of the MMES Flash Programs
* @extends MovieClip
*/
public class MMESCommon extends MovieClip {
/**
* LetterScore function
* Funtion to take numberal score and return a letter grade.
* @param score
* @return String: The letter grade earned
*/
public function LetterScore(score:int):String {
var retval:String = "";
if (score >= 90 && score <= 100) {
retval = "A";
} else if (score >= 80 && score <= 89) {
retval = "B";
} else if (score >= 70 && score <= 79) {
retval = "C";
} else if (score >= 60 && score <= 69) {
retval = "D";
} else if (score >= 50 && score <= 59) {
retval = "F";
} else {
retval = '--';
}
return retval;
}
}
}
What could I be doing wrong? Thanks for any help, Troy