Scrolling a list/movieclip in flash5.5 (not flex) your best script?.. this is my script..
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() { } } }
