00:00
00:00
Newgrounds Background Image Theme

VelvetsFunzone just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

static class troubles

645 Views | 5 Replies
New Topic Respond to this Topic

static class troubles 2012-06-14 13:13:08


...I can't believe I'm posting this... Sorry for the relatively "simple" question, but here goes.

So, I've been using a static class called Maths that contains my own mathematical functions (such as significant figure rounding, angle and distance functions, etc.). I made it static for the same reasons AS3 makes it's Math class static; to avoid declaring a class instance to reference internal functions.

My troubles arise when I reference these static functions inside of another class. They work perfectly fine when called upon the stage:

//this is on the stage/Document class
import engine.utils.Maths;
trace(Maths.FOOBAR());

Yet do not work when called upon inside of my own classes:

//this is in a custom class
package engine
{
	import engine.utils.Maths;
	
	public class Shapes
	{
		public function Shapes():void
		{
			trace(Maths.FOOBAR());
		}
	};
};

And yet, oddly enough again, works perfectly fine when using FlashDevelop, but when making small demo projects in Flash itself, gives me the ever fruitful error message:

1061: Call to a possibly undefined method FOOBAR through a reference with static type Class.

I've really stumped myself here... No amount of Google could help me... I would appreciate any help you guys could offer, or alternative solutions suggested.

Again, thanks a lot Newgrounds community, you're always so helpful and friendly :)

Best regards,
Mike


BBS Signature

Response to static class troubles 2012-06-14 13:26:17


Flash can't find the class. So in a nutshell: "engine.utils.Maths" path is wrong. Find out where the class really is located. And tbh, I don't understand why you are trying to make it work in flash when you say you have flash develop and everything works fine there.


You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.

Response to static class troubles 2012-06-14 13:30:00


At 6/14/12 01:13 PM, mikeMarek wrote: ...I can't believe I'm posting this... Sorry for the relatively "simple" question, but here goes.

So, I've been using a static class called Maths that contains my own mathematical functions (such as significant figure rounding, angle and distance functions, etc.). I made it static for the same reasons AS3 makes it's Math class static; to avoid declaring a class instance to reference internal functions.

My troubles arise when I reference these static functions inside of another class. They work perfectly fine when called upon the stage:

//this is on the stage/Document class
import engine.utils.Maths;
trace(Maths.FOOBAR());

Yet do not work when called upon inside of my own classes:

//this is in a custom class
package engine
{
import engine.utils.Maths;

public class Shapes
{
public function Shapes():void
{
trace(Maths.FOOBAR());
}
};
};

And yet, oddly enough again, works perfectly fine when using FlashDevelop, but when making small demo projects in Flash itself, gives me the ever fruitful error message:

1061: Call to a possibly undefined method FOOBAR through a reference with static type Class.

I've really stumped myself here... No amount of Google could help me... I would appreciate any help you guys could offer, or alternative solutions suggested.

Again, thanks a lot Newgrounds community, you're always so helpful and friendly :)

Best regards,
Mike

Maths - you Englanders are going to drive me crazy with your grammar xD

anyway - i'm not sure exactly what's going on (as we don't have the actual class), but I did a quick google and it came up with some possible solutions

I know you already said you've googled it, but maybe I used different wording. Check it out anyway :P


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to static class troubles 2012-06-14 13:32:55


Maths - you Englanders are going to drive me crazy with your grammar xD

Mathematics
Maths

Response to static class troubles 2012-06-14 13:40:44


@ProfessorFlash: It's not the pathing that's wrong; I tried calling non-static methods from a completely different class located in the same path, and it works fine.

@egg82: I'm Canadian, I only used Maths since it's similar to Math and it keeps naming conventions pretty easy to remember lol. I thought the same thing upon creating the class though, "let's use American spelling convention for this!"
The Google page, however, had every link purple'd out except the first link haha. I already skimmed through most of them lol. I will try wording everything differently in some future searches, so thanks for the hint.
Love the signature btw, same reason I became a programmer :3

I'll re-post this as SOLVED if I ever do figure this out... Thanks for the couple of posts though! Quick responses, you guys are great!


BBS Signature

Response to static class troubles 2012-06-14 14:01:35


HAHAHAHAHAHHAHAHAHAHAHHA

You guys aren't gonna fucking believe this....

It had to do with the LITERAL naming of the class...

I changed the class name to Mathz (you know, because every cool mathematician spells with a Z) and it worked like a charm... I swear to God if I ever meet the designer of AS3 I'm gonna punch him it the skull...

So, I guess you could say this thread is RESOLVED.

Thanks for those two posts ProfessorFlash and egg82, sending good vibes your way :)

Cheers,
Mike


BBS Signature