Actionscript 3 和 Flex 4 通过触摸滚动 TileList
Actionscript 3 and Flex 4 scroll TileList with touch
我遇到了 Adobe Flex 4 和 ActionScript 3 的问题。
我在 Flex 4 中有一个像这样的 TileList:
<mx:TileList id="myList" change="test(event)" paddingLeft="28" width="1080" wordWrap="true" height="1420" rowHeight="475" columnWidth="350" dataProvider="{floorPlans}" itemRenderer="FloorplanItems" selectionColor="#ffffff" rollOverColor="#ffffff">
</mx:TileList>
而且我正在尝试通过触摸使其可滚动,因为这是在触摸屏上进行的,我尝试了两种不同的方法来使其通过触摸可滚动,一种将其包装在 spark Scrollable 中,如下所示:
<s:Scroller>
<s:Group>
<mx:TileList id="myList" change="test(event)" paddingLeft="28" width="1080" wordWrap="true" height="1420" rowHeight="475" columnWidth="350" dataProvider="{floorPlans}" itemRenderer="FloorplanItems" selectionColor="#ffffff" rollOverColor="#ffffff">
</mx:TileList>
</s:Group>
</s:Scroller>
但是当我在触摸屏上进行测试时,没有任何反应。
另一种方法是添加一个 TransformGestureEvent.GESTURE_SWIPE 事件侦听器,如下所示:
<mx:Script>
<![CDATA[
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
Multitouch.inputMode = MultitouchInputMode.GESTURE;
import flash.events.Event;
public function init(): void
{
trace("here");
myList.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
}
public function onSwipe (e:TransformGestureEvent):void{
if (e.offsetY == 1) {
//User swiped towards bottom
myList.y += 100;
}
if (e.offsetY == -1) {
//User swiped towards top
myList.y -= 100;
}
}
]]>
</mx:Script>
但同样,这没有任何作用....我 运行 没有想法...如何让我的 TileList 可以通过触摸滚动?
您应该使用 interactionMode 属性:
<mx:TileList interactionMode="touch"/>
可能的值为 "touch" 或 "mouse"。
由于 Spark 组件较新且专为移动性能而设计,因此建议使用 <s:List/>
而不是 <mx:TileList />
。
我遇到了 Adobe Flex 4 和 ActionScript 3 的问题。
我在 Flex 4 中有一个像这样的 TileList:
<mx:TileList id="myList" change="test(event)" paddingLeft="28" width="1080" wordWrap="true" height="1420" rowHeight="475" columnWidth="350" dataProvider="{floorPlans}" itemRenderer="FloorplanItems" selectionColor="#ffffff" rollOverColor="#ffffff">
</mx:TileList>
而且我正在尝试通过触摸使其可滚动,因为这是在触摸屏上进行的,我尝试了两种不同的方法来使其通过触摸可滚动,一种将其包装在 spark Scrollable 中,如下所示:
<s:Scroller>
<s:Group>
<mx:TileList id="myList" change="test(event)" paddingLeft="28" width="1080" wordWrap="true" height="1420" rowHeight="475" columnWidth="350" dataProvider="{floorPlans}" itemRenderer="FloorplanItems" selectionColor="#ffffff" rollOverColor="#ffffff">
</mx:TileList>
</s:Group>
</s:Scroller>
但是当我在触摸屏上进行测试时,没有任何反应。
另一种方法是添加一个 TransformGestureEvent.GESTURE_SWIPE 事件侦听器,如下所示:
<mx:Script>
<![CDATA[
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
Multitouch.inputMode = MultitouchInputMode.GESTURE;
import flash.events.Event;
public function init(): void
{
trace("here");
myList.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
}
public function onSwipe (e:TransformGestureEvent):void{
if (e.offsetY == 1) {
//User swiped towards bottom
myList.y += 100;
}
if (e.offsetY == -1) {
//User swiped towards top
myList.y -= 100;
}
}
]]>
</mx:Script>
但同样,这没有任何作用....我 运行 没有想法...如何让我的 TileList 可以通过触摸滚动?
您应该使用 interactionMode 属性:
<mx:TileList interactionMode="touch"/>
可能的值为 "touch" 或 "mouse"。
由于 Spark 组件较新且专为移动性能而设计,因此建议使用 <s:List/>
而不是 <mx:TileList />
。