AS3:gotoAndPlay 不起作用
我试图在符号内的某个帧中使用 AS3 gotoAndPlay,我的目标帧位于另一个符号内,即 “Carrera” (类名)。这两个符号都是通过从库中拖动来放置在场景上的。
我尝试过:
MovieClip(carrera).gotoAndPlay(1);
错误输出:
TypeError: Error #1034: Type Coercion failed: cannot convert carrera$ to flash.display.MovieClip.
at fondoUcreativa/frame500()
还尝试过:
carrera.gotoAndPlay(1);
编译器错误:
Symbol 'fondo Ucreativa', Layer 'Layer 2', Frame 500, Line 4 1061: Call to a possibly undefined method gotoAndPlay through a reference with static type Class.
I'm trying to gotoAndPlay using AS3 in a certain frame inside a symbol, my target frame is inside another symbol which is "Carrera" (class name). Both symbols where placed on the scene by dragging from the library.
I've tried with:
MovieClip(carrera).gotoAndPlay(1);
Error Output:
TypeError: Error #1034: Type Coercion failed: cannot convert carrera$ to flash.display.MovieClip.
at fondoUcreativa/frame500()
Also tried with:
carrera.gotoAndPlay(1);
Compiler Error:
Symbol 'fondo Ucreativa', Layer 'Layer 2', Frame 500, Line 4 1061: Call to a possibly undefined method gotoAndPlay through a reference with static type Class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要使用“gotoAndPlay”方法,您的 Carrera 类必须扩展 MovieClip。
To use the method "gotoAndPlay" your Carrera class must extends MovieClip.
你自己也说了。
carrera
是一个类,而不是一个实例。因此,您无法访问carrera.gotoAndPlay()
,它是实例方法,而不是静态方法。您必须从属性面板中命名该类的实例(例如
carreraInst
)然后您可以将其称为
carreraInst.gotoAndPlay(1);
有点题外话,按照惯例,类名以大写字母开头,所以应该是
Carrera
而不是carrera
You said it yourself.
carrera
is a Class, not an instance. Hence, you can not accesscarrera.gotoAndPlay()
which is an instance method, not a static method.You're going to have to name the instance of that class (say
carreraInst
), from the properties panelThen you can call it as
carreraInst.gotoAndPlay(1);
On a somewhat off-topic note, class names, by convention, begin with an upper case letter, so it should have been
Carrera
instead ofcarrera