I'm having trouble with a custom scroller. I want it to go left to right and
NOT up and down as it currently does. I thought I could just switch the x and y
coordinates and letters and it would work but it still scrolls upand down.
Thanks for any help.
stop();
var scrollLeft:Number = 107.5;
var scrollRight:Number = 666.8;
var imageLeft:Number = 23;
var imageRight:Number = -639;
var scrollRange:Number = scrollRight - scrollLeft;
var imageRange:Number = imageRight - imageLeft;
function scroll() {
var moved:Number = scroller._y - scrollLeft;
var pctMoved:Number = moved/scrollRange;
var imageMove:Number = pctMoved*imageRange;
images._y = imageRight - imageMove;
}
scroller.onPress = function() {
this.startDrag(false,this._x,scrollLeft,this._x,scrollRight);
this.onMouseMove = scroll;
}
scroller.onRelease = scroller.onReleaseOutside = function() {
this.stopDrag();
}
Heroina - 19 Jul 2008 17:06 GMT
You don't have all the changes necesary to make it left to right. Here
are the changes you need:
function scroll() {
var moved:Number = scroller._x - scrollLeft;
var pctMoved:Number = moved/scrollRange;
var imageMove:Number = pctMoved*imageRange;
images._x = imageRight - imageMove;
}
scroller.onPress = function() {
this.startDrag(false,scrollLeft,this._y,scrollRight,this._y);
this.onMouseMove = scroll;
}
Cheers.
Carla Macías
http://codigometropoli.com/
Noelbaland - 20 Jul 2008 08:35 GMT
Change all your _y references in the scroll function to _x.
function scroll() {
var moved:Number = scroller._x - scrollLeft;
var pctMoved:Number = moved/scrollRange;
var imageMove:Number = pctMoved*imageRange;
images._x = imageRight - imageMove;
}