Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Scroll for iphone/android

Explorer ,
Aug 02, 2013 Aug 02, 2013

Hi,

I want to do touch scroll exactly like iphone and android like (http://www.greensock.com/throwprops/) How to do that? I want the same kind of component in Flash cs6. Where could i found it? or how to do that?

Note: I am using Adobe flash cs6, Actionscript 3.0 to publish the iphone/android applications.

Thanks,

Siva

TOPICS
ActionScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2013 Aug 02, 2013

:

private function listTouchBeginF(e:TouchEvent):void{

            if(this.listP.height>this.mask_mc.height){

                stage.addEventListener(TouchEvent.TOUCH_END,listTouchEndF,false,0,true);

                if(!this.listP.cacheAsBitmap){

                    this.listP.cacheAsBitmap = true;

                }

                // 150 and 300 are to allow drag beyond listP borders and allow tween back to borders.

                dragRect.y = this.mask_mc.y-this.listP.height+this.mask_mc.height-150;

                dragRect.height = this.listP.height-this.mask_mc.height+300;

                this.listP.startTouchDrag(e.touchPointID,false,dragRect);

                //startDragY = this.listP.y;

                //startDragTime = getTimer();

                this.listP.addEventListener(Event.ENTER_FRAME,listTouchMoveF,false,0,true);

            }

        }

        private function listTouchMoveF(e:Event):void{

            startDragY = this.listP.y;

            startDragTime = getTimer();

        }

        private function listTouchEndF(e:TouchEvent):void{

            stage.removeEventListener(TouchEvent.TOUCH_END,listTouchEndF,false);

            this.listP.removeEventListener(Event.ENTER_FRAME,listTouchMoveF,false);

            this.listP.stopTouchDrag(e.touchPointID);

            dragTime = getTimer()-startDragTime;

            // predict end point, duration.  if abs <500, converge slowly.  if abs>900, converge quickly

            velocity = 1000*(this.listP.y-startDragY)/dragTime;

           

            if(velocity>0){

                // lowerLimit = this.mask_mc.y, assigned in init()

                endY = Math.min(lowerLimit,this.listP.y+velocity);

            } else if(velocity<0){

                // this.listP.height changes depending on expanded/contracted titles

                upperLimit = this.mask_mc.y+this.mask_mc.height-this.listP.height;

                endY = Math.max(upperLimit,this.listP.y+velocity);

            } else {

                // velocity = 0;

                upperLimit = this.mask_mc.y+this.mask_mc.height-this.listP.height;

                endY = Math.min(lowerLimit,this.listP.y);

                endY = Math.max(upperLimit,endY);

            }

            //trace(velocity,this.listP.y,endY,upperLimit)

           

            if( (velocity>=0 && endY==lowerLimit) || (velocity<=0 && endY==upperLimit) ){

                duration = 1;

                TweenLite.to(this.listP,duration,{y:endY,ease:Quint.easeOut});

            } else {

                duration = (endY-this.listP.y)/velocity;

                TweenLite.to(this.listP,duration,{y:endY,ease:Quint.easeOut});

            }

        }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2013 Aug 05, 2013

hi thanks for the code... but i try to run the sample code with demo file...its giving hard reaction to get the result... if possible can u able to post the complet code (mapping name with the .fla file)? example i mapped the

1) dragRect with the scroll bar on right hand side

2) listP with the content we try to scroll

3)mask_mc with the mask for the content.... i am not sure its right or not....

when i run this i got error "1067: Implicit coercion of a value of type flash.display:MovieClip to an unrelated type flash.geom:Rectangle"

Kindly help me to finish the issue.

Thanks,

Siva

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2013 Aug 05, 2013
LATEST

that all is correct except there is no scrollbar.  dragging is done just like on a native iphone app with your finger on the screen:

private var dragRect:Rectangle = new Rectangle(0,0,0,0);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines