开发者

Flex 4: how to properly override the mouseMoveHandler in the spark List method?

I really need to override the List, spark, in order to set the localX and localY on the drag event, relative to the item renderer and not to the list top-left-corner.

override protected function mouseMoveHandler(event:MouseEvent):void{
        if (!mouseDownPoint || !dragEnabled)
            return;

        var pt:Point = new Point(event.localX, event.localY);
        pt = DisplayObject(event.target).localToGlobal(pt);

        const DRAG_THRESHOLD:int = 5;

        if (Math.abs(mouseDownPoint.x - pt.x) > DRAG_THRESHOLD ||
            Math.abs(mouseDownPoint.y - pt.y) > DRAG_THRESHOLD)
        {
            var dragEvent:DragEvent = new DragEvent(DragEvent.DRAG_START);
            dragEvent.dragInitiator = this;

            var localMouseDownPoint:Point = this.globalToLocal(itemRendererMouseDownPoint);//mouseDownPoint <-- this is the only change

            dragEvent.localX = localMouseDownPoint.x;
            dragEvent.localY = localMouseDownPoint.y;
            dragEvent.buttonDown = true;

            // We're starting a drag operation, remove the handlers
            // that are monitoring the mouse move, we don't need them anymore:
            dispatchEvent(dragEvent);

            // Finally, remove the mouse handlers
            removeMouseHandlersForDragStart(); // but as this method 
            //is private I can't use it. how to do? if I had to copy paste, 
            //there is a problem too as the method 
            //"removeMouseHandlersForDragStart" 开发者_Go百科has a lot of private variables.

Any help here? please thanks } }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜