Actionscript 3 spark mobile列表上的选择仅适用于4次中的3次

Actionscript 3 spark mobile列表上的选择仅适用于4次中的3次,actionscript-3,apache-flex,air,flex4,flash-builder,Actionscript 3,Apache Flex,Air,Flex4,Flash Builder,我在Flex移动应用程序(部署在iOS和Android上)中实现Spark list时面临着一个非常严重的问题。 问题是,当触摸一个项目时,列表选择并不总是有效。事实上,有时会设置down状态,但该项目从未被选中,而之前选择的项目保持选中状态 <s:List id="myList" width="100%" height="100%"> <s:dataProvider> <s:ArrayCollection> &

我在Flex移动应用程序(部署在iOS和Android上)中实现Spark list时面临着一个非常严重的问题。 问题是,当触摸一个项目时,列表选择并不总是有效。事实上,有时会设置
down
状态,但该项目从未被选中,而之前选择的项目保持选中状态

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
通过查看
List
ListBase
类,我发现我的列表确实接收鼠标/触摸事件。
列表
项_mouseDownHandler
确实会被触发,并且对于正确提交和未正确提交的选择,其行为实际上是相同的。 到目前为止,我发现的区别是,对于不成功的选择,
commitProperties
方法(属于
ListBase
)从未被调用,因此,
List
commitSelection
也没有被调用,导致选择不会改变

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
有没有人能更深入地理解为什么这不起作用?我将非常感谢任何帮助,因为我没有看到我自己解决这个问题

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
对于任何想要重现问题的人,请设置一个Flex mobile项目,并添加一个列表,以便使用简单的内联渲染器和一些通用对象进行查看,如下所示:

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>

.....

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
然后用手指在设备上随机选择项目,看看会发生什么,即使触摸屏幕,项目也不会被选中,有时会显示向下的颜色

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
编辑: 哦,不要把注意力集中在第四项中的第三项上,你必须尝试更多的次数,而不是仅仅4次,才能看到问题所在,但我想大约75%是一个很好的估计

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
编辑2: 由于其他人显然遇到了相同的问题,我在Flex Jira中提交了一份错误报告:
好的,初步的解决方案(虽然我认为这是一个黑客,因为我不知道它是否不会引起其他问题)如下:p>
<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
为spark列表创建子类,覆盖
项\u mouseDownHandler
,并专门设置所选索引

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
 override protected function item_mouseDownHandler(event:MouseEvent):void {
     setSelectedIndex((event.currentTarget as IItemRenderer).itemIndex);
 }

同样,这在第一眼看来确实有效,但当然需要测试。会让你们不断更新的

我将下面所示的代码与“默认”Flex 4.6一起使用。我相信Flex 4.6与AIR 3.1是本地发布的,而不是您所使用的3.3

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
我无法复制所描述的问题。我在摩托罗拉Xoom(安卓3)、HTC Evo 3D(安卓4)、iPad第一代和iPad第三代上进行了测试

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
我确实注意到,有时在iPad上,如果我手指按得太快或触摸列表行之间的行,某个项目将无法选择;然而,这是很难复制。在这些情况下,从不设置关闭状态;因此,媒体似乎没有登记。我想这是因为在这种情况下我的触觉太轻了

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
我的结论如下:

<s:List id="myList" width="100%" height="100%">
    <s:dataProvider>
        <s:ArrayCollection>
            <fx:Object label="Item1" />
                         .....
            <fx:Object label="Item30" />
        </s:ArrayCollection>
    </s:dataProvider>
</s:List>
  • 在AIR3.3中有一个bug并没有在AIR3.1中出现
  • iPad2上发生了一些奇怪的事情,而其他设备上却没有
  • 您自定义的Flex 4.6和AIR 3.3的合并有问题
  • 我在测试中使用的代码:

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
    
        <s:List id="myList" width="100%" height="100%">
            <s:dataProvider>
                <s:ArrayCollection>
                    <fx:Object label="Item1" />
                    <fx:Object label="Item2" />
                    <fx:Object label="Item3" />
                    <fx:Object label="Item4" />
                    <fx:Object label="Item5" />
                    <fx:Object label="Item6" />
                    <fx:Object label="Item7" />
                    <fx:Object label="Item8" />
                    <fx:Object label="Item9" />
                    <fx:Object label="Item10" />
                    <fx:Object label="Item11" />
                    <fx:Object label="Item12" />
                    <fx:Object label="Item13" />
                    <fx:Object label="Item14" />
                    <fx:Object label="Item15" />
                    <fx:Object label="Item16" />
                    <fx:Object label="Item17" />
                    <fx:Object label="Item18" />
                    <fx:Object label="Item19" />
                    <fx:Object label="Item20" />
                    <fx:Object label="Item21" />
                    <fx:Object label="Item22" />
                    <fx:Object label="Item23" />
                    <fx:Object label="Item24" />
                    <fx:Object label="Item25" />
                    <fx:Object label="Item26" />
                    <fx:Object label="Item27" />
                    <fx:Object label="Item28" />
                    <fx:Object label="Item29" />
                    <fx:Object label="Item30" />
                </s:ArrayCollection>
            </s:dataProvider>
        </s:List>
    
    </s:Application>
    

    我也有同样的问题。我想说清楚:

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    
    • 问题是:通过触摸从列表中选择项目,有时选择不会改变;出现这种情况时,您应触摸2或3次,然后才能更改选择
    • 它只出现在iPad和iPhone设备上,不在模拟器上
    • 很难重现,因为不容易理解受影响的情况
    • 我可以假设它是在一个滚动动作之后发生的,当然是轻触(但是轻触是发生的,所以“轻触”不是问题…)
    我没有解决方案,但我想与大家分享,以强调这是一个影响用户体验的真正严重的bug(我在app store上对此也有负面评论…)

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    

    再见

    我把这个贴在了提交的bug上(https://issues.apache.org/jira/browse/FLEX-33169),但我想我也会在这里发布这些信息:

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    
    我不太确定这是一个错误

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    
    在带有鼠标的桌面上,列表会在鼠标按下时选择项目。但是,在触摸交互模式的设备上,列表会在鼠标向上移动时选择项目。主要原因是用户可能希望滚动,而不是实际选择项目(例如,选择项目可能会转换到新屏幕)。Down与selected不同,项目可能处于Down状态,然后进入Down和selected状态(然后进入selected状态),也可能返回正常状态。“向下”和“选定”之间的区别很微妙,但“向下”是向用户显示,他们在可能选择的内容之上,但“选定”意味着他们实际上已经选择了该内容

    <s:List id="myList" width="100%" height="100%">
        <s:dataProvider>
            <s:ArrayCollection>
                <fx:Object label="Item1" />
                             .....
                <fx:Object label="Item30" />
            </s:ArrayCollection>
        </s:dataProvider>
    </s:List>
    
    在鼠标按下时,列表跟踪单击的项目,如果滚动尚未启动,则在鼠标向上时,该项目将被选中。通过在List.removeMouseHandlersForDragStart()和List.touchInteractionStartHandler()中放置断点,可以看到发生了什么。如果滚动被触发,您将看到列表。