flash - Make a Flex/AIR scroller with an HGroup "snap" to each item when scrolling completes -


i'm developing app android devices using flash builder burrito , having trouble figuring out how accomplish 1 aspect of app.

i have hgroup inside of scroller. hgroup has images 400px in width , have width of each hgroup column set 400px. although number of items dynamic, assume have 10 images in hgroup. width of scroller , viewport set 400px.

so far -- user can see single image within scroller. user can scroll left or right using touch or mouse , see each image. here's i'm stuck. want make when user stops scrolling scroller "snaps" image view. in other words, don't want half of 1 image , half of image in viewport.

seems pretty straightforward can't figure out. part of issue there doesn't seem event use purpose. know can hook in propertychangeevent.property_change or mouseevent.mouse_up/touchevent.touch_end (which i'm doing now) event doesn't give me need.

i need event fires when user releases mouse part of scroll or lifts finger off device part of scroll. and need wait scroll stop. example, if fast swipe need wait scroller stop or stop before perform snap. event fires let go of mouse or take finger off tablet, if alter horizontal scroll pos gets overwritten "slowing down of scroller".

by way, know can use modulus logic show each image "whole". that's not i'm stuck -- i'm stuck @ event use know when perform mod logic.

note i've developed works fine if scroll , let off mouse. it's when slide more rapidly ceases work.

here's partially working code:

private function onvehiclescrollermouseup(event:event):void {     snapscroller(); }  private function onvehiclescrollertouchend(event:event):void {     snapscroller(); }  private function snapscroller():void {     // if user didn't stop @ interval of 400, snap interval     var newscrollposition:uint = vehiclescroller.viewport.horizontalscrollposition uint;      var modscrollposition:uint = newscrollposition % 400;     var snapscrollposition:uint;     if (modscrollposition == 0)         snapscrollposition = newscrollposition;     else     {         if (modscrollposition <= 200)             snapscrollposition = newscrollposition - modscrollposition;         else             snapscrollposition = newscrollposition - modscrollposition + 400;      }     vehiclescroller.viewport.horizontalscrollposition = snapscrollposition number; } 

thanks in advance!

multitouch.inputmode = multitouchinputmode.gesture;

then listen gesturepan and/or gestureswipe events.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -