Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
:
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});
}
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now