I'm lost. For the life of me I can't seem to create and import my own class. I've read so many posts and on it and even followed tutorials (which have worked fine), but now that it's all my original work, no dice!
So, my .as file named GeoMath, which contains the class I'd like to import, looks like this:
package {
public class GeoMath {
public function GeoMath() {
// Get Distance Between 2 points.
public function distance(x1: Number, x2: Number, y1: Number, y2: Number): Number {
var d: Number;
d = Math.pow(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2), .5);
return d;
}... etc.
and this .as file is in the same folder as my .fla file. Incidentally, it also has another two .as files that have Sprite
extensions that I am successfully instantiating. Ok, now the main class:
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.*;
import GeoMath; // C:\Users\User\Desktop\oldProjects\oldProject_1
...
public class Document extends MovieClip {
...
mouseVel = distance(me.stageX, mouseLastX, me.stageY, mouseLastY);
...Document.as, Line 174, Column 17 1180: Call to a possibly undefined method distance.
I have tried putting a folder called 'calculations' in the same folder as the .fla, and then putting GeoMath.as in THAT folder, and then doing this in the GeoMath.as file:
package calculations {
...
and in the main class doing this:
import calculations.GeoMath
but this has returned the same results. I'm I blind or just stupid? Thanks for taking a look. It will be much appreciated as I'm bleeding out of my eyes by now.