Skip to main content
Known Participant
June 6, 2011
Question

Scrolling a list/movieclip in flash5.5 (not flex) your best script?.. this is my script..

  • June 6, 2011
  • 8 replies
  • 3662 views

Hi,

I want to create a good class for this as I know I will use it alot. So I want to get it right!...

I want to create a script that will allow a user to scroll through a list of items on there phone.

My script is missing some inertia, but it works....

If any one can improve and is willing to share please post.

package com  {      import com.*      import flash.display.MovieClip;      import flash.geom.Point;            import flash.ui.Multitouch      import flash.events.TouchEvent      import flash.events.GestureEvent      import flash.events.PressAndTapGestureEvent      import flash.ui.MultitouchInputMode;            Multitouch.inputMode = MultitouchInputMode.GESTURE;            public class MobileScroller{           public var troot:MovieClip;           public var model:Model                      public var scrollPan:MovieClip                      public var itemMoving:Boolean = false;           public var itemMOVED:Boolean = false;           public var _mouseDownPoint:Point           public var _mouseDownY:int                           public function MobileScroller(_troot,_model) {                troot = _troot                model = _model                     }                      public function iniz(_scrollPan:MovieClip) {                scrollPan = _scrollPan;                startScrollingItems();           }                      public function startScrollingItems(){                if(Multitouch.supportsTouchEvents){                     Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;                                         square_mc.tappedItem.addEventListener(TouchEvent.TOUCH_TAP, tappadItem);                     scrollPan.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);                     scrollPan.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);                     scrollPan.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);                }                          }                                public function onTouchBegin(e:TouchEvent) {                trace("on touch begin")                itemMoving = false;                          itemMOVED = false                _mouseDownPoint = new Point(e.stageX, e.stageY);                _mouseDownY = scrollPan.y;                                          }                      public function onTouchEnd(e:TouchEvent) {                itemMoving = false;           }                      public function tappadItem(e:TouchEvent) {                if (itemMOVED == true) {                     trace("should do somthing");                }           }                      public function onTouchMove(e:TouchEvent) {                var crad:MovieClip = scrollPan                itemMoving = true;                itemMOVED = true                if(crad.y <_mouseDownY-4 || crad.y >_mouseDownY+4){                     itemMoving = true;                }                     var point:Point = new Point(e.stageX, e.stageY);                crad.y = _mouseDownY + (point.y - _mouseDownPoint.y);                                         }                      public function cleanup() {           }      } }

This topic has been closed for replies.

8 replies

sinious
Legend
March 12, 2012

I always had to use blitting to get large lists to scroll with any usable performance.

Here's an example of some prewritten blit code: http://www.greensock.com/blitmask/

The new spark lists scroll pretty well for me, not even close to native but not unusable.

I'm speaking specifically for use on mobile devices.

Inspiring
March 13, 2012

Does this make sense for for a list with customer item renderers on flex? use of blitting.

If I understand correctly it won’t because flex does renderer re-use and re-rendering of item renderers so can’t figure out full bitmap to cache?

If I was to disable this and not allow re-use could I then theoretically work out the full bitmap and make use of this technique?

Would really like to get flick scrolling on my flex project closer to the native experience.

Colin Holgate
Inspiring
March 13, 2012

If you haven't already tried it, try AIR 3.2 with the renderMode set to "direct". Thatt ought to perform well with scrolling lists.

markc888
Inspiring
March 9, 2012

I've just created a reusable list class that emulated the iOS list style.

http://www.infin8iphone.co.uk/?p=57

relaxatraja
Inspiring
June 7, 2011

Here is a component with the source code:

http://code.google.com/p/as3-iphone-scroll/downloads/list

A sample program:

http://www.shinedraw.com/text-effect/silverlight-3-and-flash-iphone-dragging-effect/