【发布时间】:2013-01-20 12:42:50
【问题描述】:
我这几天一直在想如何在触摸设备上像所有其他应用一样平滑滚动。目前我已经实现了这个:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);
function fl_SwipeHandler(event:TransformGestureEvent):void
{
switch(event.offsetX)
{
// swiped right
case 1:
{
// Start your custom code
// This example code moves the selected object 20 pixels to the right.
// End your custom code
break;
}
// swiped left
case -1:
{
// Start your custom code
// This example code moves the selected object 20 pixels to the left.
// End your custom code
break;
}
}
switch(event.offsetY)
{
// swiped down
case 1:
{
// Start your custom code
// This example code moves the selected object 20 pixels down.
if (PActive == true) {
dgPlace.verticalScrollPosition = dgPlace.verticalScrollPosition - 60;
}
if (SActive == true) {
dgSubject.verticalScrollPosition = dgSubject.verticalScrollPosition - 60;
}
if (OActive == true) {
dgObject.verticalScrollPosition = dgObject.verticalScrollPosition - 60;
}
if (FActive == true) {
dgFeeling.verticalScrollPosition = dgFeeling.verticalScrollPosition - 60;
}
if (AActive == true) {
dgAction.verticalScrollPosition = dgAction.verticalScrollPosition - 60;
}
if (NActive == true) {
dg.verticalScrollPosition = dg.verticalScrollPosition - 60;
}
// End your custom code
break;
}
// swiped up
case -1:
{
// Start your custom code
// This example code moves the selected object 20 pixels up.
if (PActive == true) {
dgPlace.verticalScrollPosition = dgPlace.verticalScrollPosition + 60;
}
if (SActive == true) {
dgSubject.verticalScrollPosition = dgSubject.verticalScrollPosition + 60;
}
if (OActive == true) {
dgObject.verticalScrollPosition = dgObject.verticalScrollPosition + 60;
}
if (FActive == true) {
dgFeeling.verticalScrollPosition = dgFeeling.verticalScrollPosition + 60;
}
if (AActive == true) {
dgAction.verticalScrollPosition = dgAction.verticalScrollPosition + 60;
}
if (NActive == true) {
dg.verticalScrollPosition = dg.verticalScrollPosition + 60;
}
// End your custom code
break;
}
}
这基本上只是说如果发生滑动,则将活动数据网格向上或向下滚动 60 个单位,即 2 行。如果有人知道如何做到这一点,我将不胜感激。 ^_^
【问题讨论】:
-
我不确定我是否理解您的问题。首先,滑动不是滚动!为什么要为数据网格实现自己的滚动实现?网格带有它自己的滚动容器。如果您想对网格使用某种滑动方式(无论出于何种原因),我强烈建议您使用 Gestouch 库。
-
滑动滚动在 Air iOS 应用程序的数据网格中无法原生工作。感谢您的建议,我会试一试。
标签: ios actionscript-3 air scroll touch