Public Function Allegedly Doesn't Exist?

2019-03-01 09:53发布

问题:

Okay, I am at the end of my rope.

I have a Flash Professional CS5.5, Adobe AIR, Actionscript 3 project. So far, I've never had this problem before...

I have a custom class called Prefs, that I wrote myself. This class has a number of functions. The ones I wrote a couple weeks ago, I can call in my code with no problem. But the ones in the SAME CLASS that I wrote today are throwing an error.

This one works:

public function UserFetch(ID:String):*
{

This one doesn't:

public function Set(setting:String, val:*):void
{

I call both the same way. In the document class "base":

package  {

    import flash.display.MovieClip;
    import trailcrest.prefs.prefs;

    public class base extends MovieClip {

        public static var Prefs:prefs = new prefs();
    }

}

In my timeline code.

base.Prefs.UserFetch("musictoggle");
base.Prefs.Set("musictoggle", true);

The first fires fine. The second gives this error:

Scene 1, Layer 'Layer 1', Frame 1, Line 4 1061: Call to a possibly undefined method Set through a reference with static type prefs.

What is going on? I can find absolutely no legitimate reason why this should be happening. Like I said, it has never happened before, and it not happening on any other class or function.

回答1:

After a bit of discussion in the chat, we found that flash was not picking up on the changes made in the prefs.as-file. Changing the name of the class fixed the issue (It may have been a weird compiler cache problem).