grayhalo
03-27-2005, 02:48 AM
I've written a bunch of code to allow people to scroll left-to-right across an interactive map. Everything works nicely except I have one really weird problem. Before I enable the onEnterFrame action that allows the user to scroll around, I set the value of map_mc._x to the center of the screen. But what happens when it loads up is I get a little "bounce". Ie it loads up in the right place, bounces to the left slightly and then re-centers. Here's my code for the initialization and onEnterFrame action:
map_mc.init = function() {
this.doSomeStuff();
trace("centering view...");
this._x = -340; //Number(-1)*(totalWidth-viewableAreaWidth)/2;
trace("initializing movement...");
this.onEnterFrame = this.frameScroller;
};
map_mc.frameScroller = function() {
viewWidth = 780;
mapWidth = 1460;
easing = 8;
moveRatio = mapWidth/viewWidth;
moveDist = int(_root._xmouse-_root._xmouse*moveRatio) - this._x;
this._x += int(moveDist/easing);
if (this._x > 0) this._x = 0;
if (this._x < -1460+780) this._x = -1460+780;
};
I have *no idea* why this is happening and it's incredibly frustrating. Been staring at it for hours and it's probably something silly. I hope someone can help.
map_mc.init = function() {
this.doSomeStuff();
trace("centering view...");
this._x = -340; //Number(-1)*(totalWidth-viewableAreaWidth)/2;
trace("initializing movement...");
this.onEnterFrame = this.frameScroller;
};
map_mc.frameScroller = function() {
viewWidth = 780;
mapWidth = 1460;
easing = 8;
moveRatio = mapWidth/viewWidth;
moveDist = int(_root._xmouse-_root._xmouse*moveRatio) - this._x;
this._x += int(moveDist/easing);
if (this._x > 0) this._x = 0;
if (this._x < -1460+780) this._x = -1460+780;
};
I have *no idea* why this is happening and it's incredibly frustrating. Been staring at it for hours and it's probably something silly. I hope someone can help.