Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 调用函数AS3_Actionscript 3 - Fatal编程技术网

Actionscript 3 调用函数AS3

Actionscript 3 调用函数AS3,actionscript-3,Actionscript 3,这是我的函数,我想从中获取一些功能以供使用(另一个类中的另一个函数)。基本上,我如何从另一个类调用它,同时保留当前类中的所有数据(函数)。类方法是绑定的,除非您强制传递另一个对象,否则它们将坚持自己的对象。这意味着,只要你可以引用你的函数,你就可以从任何地方调用它 解决方案1:。假设您只有/只需要使用该方法的类的一个实例,则将引用放在类静态变量上,并可以将其称为YourClass.instance.yourMethod(args) public function PubliCTest(_arg_

这是我的函数,我想从中获取一些功能以供使用(另一个类中的另一个函数)。基本上,我如何从另一个类调用它,同时保留当前类中的所有数据(函数)。

类方法是绑定的,除非您强制传递另一个对象,否则它们将坚持自己的对象。这意味着,只要你可以引用你的函数,你就可以从任何地方调用它

解决方案1:。假设您只有/只需要使用该方法的类的一个实例,则将引用放在类静态变量上,并可以将其称为YourClass.instance.yourMethod(args)

public function PubliCTest(_arg_1:MouseEvent):void {
    trace("PubliCTestSub" + this.tell.text() + " , " + this.hello.text());
    if (((this.istextValid()) && (this.istextsubValid()))){
        var url:URLLoader = new URLLoader();
        var req:URLRequest = new URLRequest("http://www.nasydbasda.com/tnewabsud.php");
        var vars:URLVariables = new URLVariables();
        vars.text1 = this.text1.text();
        vars.textsub = this.textsub.text();
        req.data = vars ;
        req.method = URLRequestMethod.POST;
        url.load(req);
        url.addEventListener(Event.COMPLETE, reqcompleted);

    }
    this.onSignInSub();
}
解决方案2:静态参考。基本上是一样的,假设只有一个类实例,您可以绕过实例引用并声明一个公共变量来处理方法引用。您可以将其称为YourClass.MyMethod()

public function PubliCTest(_arg_1:MouseEvent):void {
    trace("PubliCTestSub" + this.tell.text() + " , " + this.hello.text());
    if (((this.istextValid()) && (this.istextsubValid()))){
        var url:URLLoader = new URLLoader();
        var req:URLRequest = new URLRequest("http://www.nasydbasda.com/tnewabsud.php");
        var vars:URLVariables = new URLVariables();
        vars.text1 = this.text1.text();
        vars.textsub = this.textsub.text();
        req.data = vars ;
        req.method = URLRequestMethod.POST;
        url.load(req);
        url.addEventListener(Event.COMPLETE, reqcompleted);

    }
    this.onSignInSub();
}
解决方案3:传递引用。如果由于有多个实例而无法使用单例(-like)解决方案,那么就直接通过应用程序体系结构传递方法引用。你可能想了解一下