ho ricevuto varie e-mail in relazione a questo post circa l'effetto di decelerazione....
allora tanto per capire come muovere qualcosa entro certi limiti..........
codice:
// scroller
mc._x=20
mc._y=20
mc._height=20
mc._width=10
// btn up
up._x=20
up._y=10
up._height=10
up._width=10
//btn dwn
dwn._x=20
dwn._y=120
dwn._height=10
dwn._width=10
// my track
mytrack._x=20
mytrack._y=20
mytrack._height=100
mytrack._width=10
// limiti e posizioni
L_SU = mc._y
L_GIU= dwn._y
P=mc._y
mc.H=mc._height
inc=5
up.onPress=function(){
this._parent.mc.scrolla=true
this._parent.moveUP()
}
up.onRelease=function(){
this._parent.mc.scrolla=false
}
dwn.onPress=function(){
this._parent.mc.scrolla=true
this._parent.moveDWN()
}
dwn.onRelease=function(){
this._parent.mc.scrolla=false
}
function moveDWN(){
mc.onEnterFrame=function(){
if(this.scrolla){
this._parent.P=this._parent.P+this._parent.inc
}
if((this._y+this.H)< this._parent.L_GIU){
this.Y=this._parent.P - this._y
this._y+=Math.round(this.Y/3)
if(this.Y==1){this._y=this._parent.P;delete this.onEnterFrame}
}else{
this.scrolla=false;this._parent.P=this._y
this._y=this._parent.L_GIU-this.H;delete this.onEnterFrame
}
}
}
function moveUP(){
mc.onEnterFrame=function(){
if(this.scrolla){
this._parent.P=this._parent.P-this._parent.inc
}
if(this._y > this._parent.L_SU+this._parent.inc){
this.Y=this._parent.P - this._y
this._y+=Math.round(this.Y/3)
if(this.Y==1){this._y=this._parent.P;delete this.onEnterFrame}
}else{
this.scrolla=false;this._parent.P=this._y
this._y=this._parent.L_SU;delete this.onEnterFrame}
}
}
Questo esempio non è lo scroller ma bensi il concetto della decelerazione comandata da 2 pulsanti che ne variano la direzione.