静态停止/播放功能

发布于 2024-12-29 01:02:09 字数 471 浏览 4 评论 0原文

假设我想使用frameScript 方法向某些帧添加一些停止和播放方法。

通常我会声明 stop 函数:

private function $FUN_FrameStop():void {
            stop();
            return;
        }

然后像这样使用它:

addFrameScript(47, $FUN_FrameStop, 122, $FUN_FrameStop);

我的问题是,如何创建与静态函数相同的 $FUN_FrameStop?

静态函数不允许使用 this 因为静态成员绑定到类并且不会被该类的实例继承。

那么,有没有办法创建一个类似于 $FUN_FrameStop 的静态函数?

Let's say I would want to use the frameScript method to add some stop and play methods to some frames.

Normally I would declare the stop function:

private function $FUN_FrameStop():void {
            stop();
            return;
        }

and then use it like this:

addFrameScript(47, $FUN_FrameStop, 122, $FUN_FrameStop);

My question is, how can I create the same $FUN_FrameStop as a static function?

Static functions do not allow the use of this since static members are bound to a class and are not inherited by that class' instances.

So, is there a way to create a function similar to $FUN_FrameStop, but static?

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

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

发布评论

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

评论(3

守不住的情 2025-01-05 01:02:10

您可以在类外部但在包中声明一个函数

package
{
    public function Func(): void
    {
         trace( "Func" );
    }
}

,然后您可以在包含包后使用 Func() 调用它(如果需要)

You may declare a function outside of class but in package

package
{
    public function Func(): void
    {
         trace( "Func" );
    }
}

then you may call it everywhare with Func() after including the package ( if needed )

追风人 2025-01-05 01:02:09

我从未动态添加任何框架脚本但是..您是否尝试使用实例作为参数?

    private static function $FrameStop($inst:MovieClip):void {
        $inst.stop();
    }

I never added any frame script dynamically but.. did you try using the instance as the parameter?

    private static function $FrameStop($inst:MovieClip):void {
        $inst.stop();
    }
紫﹏色ふ单纯 2025-01-05 01:02:09

答案是,除非我有对类实例的静态引用,否则没有办法,但这不是我想要的。

public static var staticClassRef:MovieClip;
function $FUN_FrameStop():void {
staticClassRef.stop();
return;
}

The answer is that there's no way unless I have a static reference to the class instance, but that's not what I want.

public static var staticClassRef:MovieClip;
function $FUN_FrameStop():void {
staticClassRef.stop();
return;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文