开发者

actionscript error: Call to a possibly undefined method

开发者 https://www.devze.com 2023-01-25 09:55 出处:网络
those files are in the 开发者_开发技巧same folder: my .as file package {public function YAAY():int{return(3);};}

those files are in the 开发者_开发技巧same folder:

my .as file package {public function YAAY():int{return(3);}; }

my main .fla trace(YAAY());

but the compiler says 1180: Call to a possibly undefined method YAAY.

I think I made an obvious mistake, but I can't figure out. Thanks


I think you forgot to correctly define your class inside the .as file. It should look like:

package {
    public class YAAYClass {
        public static function YAAY():int {
            return 3;
        }
    }
}

Have it called this way:

trace(YAAYClass.YAAY());


1: I should have named my .as file "YAAY.as" because this is the externally visible function in the file. 2: I should have type in my main .fla file that "import YAAY" thats it, problem solved, no classes needed

0

精彩评论

暂无评论...
验证码 换一张
取 消