Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/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
Actionscript 3 MouseeEvent侦听器不使用SimpleButton AS3_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 MouseeEvent侦听器不使用SimpleButton AS3

Actionscript 3 MouseeEvent侦听器不使用SimpleButton AS3,actionscript-3,flash,Actionscript 3,Flash,因此,我不得不重写一个我正在进行的项目,以避免使用Starling框架和扩展Feathers,现在我正试图让按钮正常工作。我的代码目前是 package { import flash.display.Bitmap; import flash.display.SimpleButton; import flash.events.MouseEvent; /** * ... * @author Fluzzarn */ public class StartScreen extends S

因此,我不得不重写一个我正在进行的项目,以避免使用Starling框架和扩展Feathers,现在我正试图让按钮正常工作。我的代码目前是

    package  
{
import flash.display.Bitmap;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
/**
 * ...
 * @author Fluzzarn
 */
public class StartScreen extends Screen 
{

    public var startGameButton:SimpleButton;
    public var optionsButton:SimpleButton;

    [Embed (source = "assets\\playGameButtonUp.png")]
    private var playButtonUp:Class
    [Embed (source = "assets\\playGameButtonDown.png")]
    private var playButtonDown:Class

    [Embed (source = "assets\\titleScreen.png")]
    private var backGround:Class;

    public function StartScreen() 
    {
        mouseChildren = true;
        super();
        startGameButton = new SimpleButton(new playButtonUp(), new playButtonDown());

        addChild(new backGround());
        addChild(startGameButton);
        startGameButton.addEventListener(MouseEvent.CLICK, goToGame);
        trace(startGameButton.getBounds(stage));
    }

    private function goToGame(e:MouseEvent):void 
    {
        trace("Mouse Clicked");
        Main(parent).goToGame();
    }


}
}

如果我只是让整个StartScreen对象都有MouseeEvent侦听器,那么代码就可以正常工作,但是当我将侦听器添加到按钮本身时,它永远不会触发。这可能是愚蠢的事情,但我的谷歌fu现在不适合我


编辑:Screen只是一个基类,我让游戏中的每个屏幕都从中扩展,例如GameScreen、StartScreen、OptionScreen都是我项目中的类

您没有提供hitTestState按钮-它处于非活动状态。你只给了他一个悬停状态


startGameButton=newsimplebutton(new playButtonUp(),new playButtonDown(),new playButtonDown(),new playButtonDown())

为什么要扩展
Screen
?Screen只是一个基类,其他类为了在Main中切换而扩展到它