简体   繁体   中英

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

I see where i was going wrong however when i change the instance name like you said i 1120: Access of undefined property snakePart. all of this code btw is at document class level and the movieclips are in the library not on stage

Is the instance on the stage? When you name instances, don't name them identical to your class name. Flash gets confused because you're importing a class called SnakePart but you have an instance called ... SnakePart. Instead, name it something else (ie snake_part) or at least change the case (ie snakePart - not recommended as it can lead to some issues debugging).

Change your instance name, change this code snakePart.gotoAndStop(2) and you should be gravy. Unless your actionscript is in a part of the flash (ie on another frame or not in the Document class level - preferred and recommended) that the object hasn't been instantiated yet.

To instantiate a library movieclip, try this in your Document class level, inside your constructor :

var snakePart:SnakePart = new SnakePart();
addChild(snakePart);

您正在定义“ SnakePart”上调用gotoAndStop而不是类的实例 ,如var snake_part:SnakePart = new SnakePart();

它确实做到了,实际上,您尚未在要调用的类中定义静态方法,想必您打算调用该类的实例。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM