【问题标题】:AS3: Drag to select multiple tiles in TileListAS3:拖动选择TileList中的多个图块
【发布时间】:2013-03-15 03:12:31
【问题描述】:

我正在和我的两个同学一起做一个项目,我们希望能够将光标拖到一个瓷砖列表上以选择多个瓷砖。我们真的找不到任何功能来做到这一点,是否有可能做到这一点?

最好的问候

谢谢

【问题讨论】:

    标签: actionscript-3 tilelist


    【解决方案1】:

    这应该让你知道你想要完成什么:

    tileList = new TileList();
    tileList.allowMultipleSelection = true;
    tileList.addEventListener(MouseEvent.MOUSE_DOWN, startSelecting);
    tileList.addEventListener(MouseEvent.MOUSE_UP, stopSelecting);
    
    function startSelecting(e:MouseEvent):void 
    {
        tileList.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
        if (CellRenderer(e.target))
        {
            CellRenderer(e.target).selected = true;
        }
    }
    
    function onMouseMove(e:MouseEvent):void 
    {
        if (CellRenderer(e.target))
        {
            CellRenderer(e.target).selected = true;
        }
    }
    
    function stopSelecting(e:MouseEvent):void 
    {
        tileList.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
    }
    

    您肯定会希望对其进行自定义以满足您的需求,但基本上它会在磁贴列表中添加一些鼠标事件侦听器,并选择在按下鼠标按钮时已滚动的任何磁贴。

    【讨论】:

    • 完美,正是我需要的。
    猜你喜欢
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    相关资源
    最近更新 更多