1061:通过静态类型 Class 的引用调用可能未定义的方法 gotoAndStop
我明白我哪里出了问题,但是当我像你说的那样更改实例名称时,我 1120:访问未定义的属性 SnakePart。顺便说一句,所有这些代码都位于文档类级别,并且影片剪辑位于库中而不是舞台上
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实例在舞台上吗?命名实例时,请勿将它们命名为与类名相同的名称。 Flash 会感到困惑,因为您正在导入一个名为 SnakePart 的类,但您有一个名为 ... SnakePart 的实例。相反,将其命名为其他名称(即snake_part)或至少更改大小写(即snakePart - 不推荐,因为它可能会导致一些调试问题)。
更改您的实例名称,更改此代码snakePart.gotoAndStop(2),您应该会很满意。除非您的动作脚本位于 Flash 的一部分(即位于另一帧上或不在 Document 类级别中 - 首选且推荐),否则该对象尚未实例化。
要实例化库 movieclip,请在构造函数内的 Document 类级别中尝试以下操作:
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 (i.e. snake_part) or at least change the case (i.e. 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 (i.e. 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 :
您正在类定义“SnakePart”上调用 gotoAndStop,而不是该类的实例,如
var Snake_part:SnakePart = new SnakePart();
You are calling gotoAndStop on the class definition "SnakePart" instead of an instance of the class, as in
var snake_part:SnakePart = new SnakePart();
它确实按照上面所说的那样进行,您尚未在您正在调用的类中定义静态方法,大概您打算调用该类的实例。
it does what it says on the tin really, you have not defined a static method in the class that you are calling, presumably you are meaning to call an instance of the class instead.