如何在as3中的MOUSE_DOWN上使用不同的鼠标光标?

时间:2015-12-21 23:43:10

标签: actionscript-3 flash

我是as3的新手,我需要做一件非常简单的事情。我有以下代码,它工作得很好。但我需要而且无法弄清楚如何做到这一点:

  1. 当我按住鼠标按钮时选择鼠标光标(从符号中选择)
  2. 随之移动的能力(通常当我用鼠标移动时它会消失)

        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import fl.motion.MotionEvent;
    
        var CursorStill: Sprite;
        var CursorAnim: Sprite;
    
        function init() {
          Mouse.hide();
    
          CursorStill = new CursorStillClass();
          CursorStill.mouseEnabled = false;
          CursorStill.visible = false;
    
          addChild(CursorStill);
    
          stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
          stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
          stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        }  
    
        function mouseMoveHandler(evt: MouseEvent): void {
          CursorStill.visible = true;
          CursorStill.x = evt.stageX;
          CursorStill.y = evt.stageY;
          evt.updateAfterEvent();
        }
    
        function mouseLeaveHandler(evt: Event): void {
          CursorStill.visible = false;
    
        }
    
        function mouseDownHandler (evt: MouseEvent): void {
          CursorStill.visible = false;
        }
    
        init();
    

1 个答案:

答案 0 :(得分:0)

我的一个朋友帮助了我,我想出来了。我希望它至少能帮助其他新手:)

@model List<TRZF.Web.API.Models.ProductViewModel>
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900' rel='stylesheet' type='text/css'>
    <link href="~/css/common.css" rel="stylesheet" type="text/css" media="all" />
    <link href="~/css/createBatch.css" rel="stylesheet" />
    <link href="~/css/createProduct.css" rel="stylesheet" />
    <link href="~/css/formStyles.css" rel="stylesheet" />
    <link href="~/css/jquery-ui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.11.2.min.js"></script>
    <script src="~/js/createProducts.js"></script>
    <title>Crear</title>
</head>
<body>
    <!----start-header----------->
    <div class="header_bg">
        <div class="wrap">
            <div class="header">
                <!--------start-logo------>
                <div class="logo">
                    <img src="~/images/logo.png" alt="" /><br />
                    <span>Versi&oacute;n 1.1</span>
                </div>  
                <!--------end-logo--------->
                <!----start-nav-------->    
                <div class="nav">

                </div>
                <!-----end-nav-------->
                <div class="clear"> </div>
            </div>
        </div>
    </div>
    <!------end-header------------>
    <div class="slider_bg">
        <div class="wrap">
            <div class="da-slide" style="padding:0%">
                @{
                using (Html.BeginForm("Save", "MyProduct", FormMethod.Post, new { name = "eProductsFrm", id = "eProductsFrm" }))
                {
                    <div>
                        <table class="productsList">
                            <thead>
                                <tr>
                                    <td>
                                        <h4>Producto</h4>
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <div class="group">
                                            <input type="text" 
                                                class="productClass"
                                                name="model[0].ProductName" 
                                                id="model[0].ProductName"
                                                required />
                                            @*<span class="highlight"></span>
                                            <span class="bar"></span>
                                            <label>Nombre del producto</label>*@
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td>

                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                        <table class="buttonsTable">
                            <tr>
                                <td style="text-align: left;">
                                    <input type="button" id="addrow" value="A&ntilde;adir producto" />
                                </td>
                                <td>
                                    <input type="button" class="ibtnDel"  value="Borrar &uacute;ltimo producto">
                                </td>
                            </tr>
                        </table>
                    </div>

                    <p><input type="button" id="btnSubmit" value="Crear producto(s)" /></p>
                }
                <div>
                    <p>@Html.ActionLink("Inicio", "Index", "Home")</p>
                </div>
                }
            </div>
        </div>
    </div>  
</body>
</html>

大多数学分都会转到本教程

http://danielmclaren.com/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3