在 FlashDevelop(或其他没有图形的 IDE)中更改影片剪辑

发布于 2024-12-06 05:43:30 字数 366 浏览 0 评论 0原文

我这样做是

    [Embed(source = "../lib/hfront.swf")]
    private var charfront1Class : Class;
    private var charfront1:MovieClip = new charfront1Class;

为了在FlashDevelop中创建一个movieclip对象。因为没有选项(如在 CS5 中)为库对象提供一个固有的类。

我需要做的是能够在我的角色行走时切换正在显示的影片剪辑。我是否必须为每个影片剪辑创建一个单独的类并将它们调入和调出可见性?或者有没有更好的方法,一种“切换”我当前班级指向哪个影片剪辑的方法?

谢谢

I am doing this:

    [Embed(source = "../lib/hfront.swf")]
    private var charfront1Class : Class;
    private var charfront1:MovieClip = new charfront1Class;

in order to create a movieclip object in FlashDevelop. Because there is no option (like in CS5) to give a library object a class inherently.

What I need to do is be able to switch which movie clip is being displayed as my character walks about. Do I have to create a separate class for each movieclip and call them in and out of visibility?? Or is there a better way, a way to "switch" which movie clip my current class is pointing to?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢欲 2024-12-13 05:43:30

首先嵌入不正确。如果您像这样嵌入整个 SWF,您将无法控制其时间线。

要拥有可以操作的 MovieClip,您必须嵌入此 SWF 的符号:

[Embed(source = "../lib/hfront.swf", symbol="walk")]
private var walkClass : Class;
private var walk:MovieClip = new walkClass;

[Embed(source = "../lib/hfront.swf", symbol="run")]
private var runClass : Class;
private var run:MovieClip = new runClass;

其次,确保您实际为每个动画调用 stop(),否则即使它们不在显示列表中,它们也会运行(并消耗 CPU)。

最后,这是一个(简单的)示例,显示了 2 个嵌入动画(作为扩展 Sprite 的类的子级):

// current anim
private var current:MovieClip;

// showAnim("run") or showAnim("walk")
public function showAnim(anim:String):void {
    if (current) { current.stop(); removeChild(current); }
    current = this[anim];
    addChild(current);
    current.gotoAndPlay(1);
}

Firstly the embed isn't correct. If you embed an entire SWF like that you won't be able to control its timeline.

To have a MovieClip that you can manipulate you must embed a symbol of this SWF:

[Embed(source = "../lib/hfront.swf", symbol="walk")]
private var walkClass : Class;
private var walk:MovieClip = new walkClass;

[Embed(source = "../lib/hfront.swf", symbol="run")]
private var runClass : Class;
private var run:MovieClip = new runClass;

Secondly, make sure you actually call stop() for each animation or they will run (and consume CPU) even if they are off the display list.

Finally here's a (naive) example of showing the 2 embedded anims (as children of a class extending Sprite):

// current anim
private var current:MovieClip;

// showAnim("run") or showAnim("walk")
public function showAnim(anim:String):void {
    if (current) { current.stop(); removeChild(current); }
    current = this[anim];
    addChild(current);
    current.gotoAndPlay(1);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文