Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.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
Apache flex 将事件侦听器放在不同的类中。。?_Apache Flex_Actionscript 3 - Fatal编程技术网

Apache flex 将事件侦听器放在不同的类中。。?

Apache flex 将事件侦听器放在不同的类中。。?,apache-flex,actionscript-3,Apache Flex,Actionscript 3,假设我有一个名为“Click_Here”的按钮,我在某个类文件中为它添加了一个事件侦听器,以便它在另一个类文件中运行事件处理程序。。 所以会是这样 classfile1.as Click_Here.addEventListner(MouseEvent.CLICK , buttonClicked ) ; classfile2.as public function buttonClicked (e:MouseEvent){ trace ("hello");} 有可能吗 是的,这是可能的: Cli

假设我有一个名为“Click_Here”的按钮,我在某个类文件中为它添加了一个事件侦听器,以便它在另一个类文件中运行事件处理程序。。 所以会是这样

classfile1.as

Click_Here.addEventListner(MouseEvent.CLICK , buttonClicked ) ;
classfile2.as

public function buttonClicked (e:MouseEvent){ trace ("hello");}
有可能吗

是的,这是可能的:

Click_Here.addEventListner(MouseEvent.CLICK , instanceOfClass2.buttonClicked ) ;
是的,这是可能的:

Click_Here.addEventListner(MouseEvent.CLICK , instanceOfClass2.buttonClicked ) ;

对。考虑类:

public class MyClass
{
    public function MyClass()
    {
    }

    public static function staticListener(evt:MouseEvent):void {
        trace("static");
    }

    public function instanceListener(evt:MouseEvent):void {
        trace("instance");
    }
}
现在,请执行以下操作:

Click_Here.addEventListner(ouseEvent.CLICK , MyClass.staticListener);
或:


对。考虑类:

public class MyClass
{
    public function MyClass()
    {
    }

    public static function staticListener(evt:MouseEvent):void {
        trace("static");
    }

    public function instanceListener(evt:MouseEvent):void {
        trace("instance");
    }
}
现在,请执行以下操作:

Click_Here.addEventListner(ouseEvent.CLICK , MyClass.staticListener);
或:

提及

o'reilly essential actionscript 3.0。书

这将为您提供清晰的信息。

请参阅

o'reilly essential actionscript 3.0。书

这将给你明确的解释