I am using slightly old-school easy methods to scroll some clips and it's smooth for the most part, but every second there's like an extra "jerk" visible in the scrolling. If you count in your head, 1, 2, 3, 4 that pretty much is what i see. My scrolling jerks every second as if it's being "double-incremented", on a steady cycle, yet my code is super-simple, I can't figure out what's causing this.
I know this isn't really game related, but the experts in here seem to know alot more about optimized graphics performance, so I posted here.
Check out the attached SWF. This is my code in frame 1:
Code:
var update = 0;
var pos;
// Your visible window width
var screensize = 689;
var halfx = int(screensize / 2);
// Your photos clip width and height
var scenesizex = 2159;
var scenesizey = 259;
var sensitivity = -30;
// don't touch this:
scenesizex *= -1;
stop();
//
this.onEnterFrame = function() {
// calculate the distance & speed
update = int((this._xmouse - halfx) / sensitivity);
// update the panorama scene
pos = this.SCROLLER._x += update;
// check if scene is wrapping and adjust accordingly
if (pos < scenesizex) {
this.SCROLLER._x = 0;
}
if (pos > 0) {
this.SCROLLER._x = scenesizex;
}
};
Im assuming this is just one long clip containing all the photos? If so its just the refresh rate of the flash player. sucky indeed. i would make each photo into separate mcs and then only scroll them when they should be visible in the window.
Could it be because you reset scroller to 0 whenever it is over scenesizex? I would imagine it is never exactly at that position so placing it to 0 would make slight nudge. I would not set it to exact coordinate, but add/substract the width:
if (pos < scenesizex) {
this.SCROLLER._x += scenesizex;
}
if (pos > 0) {
this.SCROLLER._x -= scenesizex;
}
Could it be because you reset scroller to 0 whenever it is over scenesizex? I would imagine it is never exactly at that position so placing it to 0 would make slight nudge. I would not set it to exact coordinate, but add/substract the width:
if (pos < scenesizex) {
this.SCROLLER._x += scenesizex;
}
if (pos > 0) {
this.SCROLLER._x -= scenesizex;
}
If that was the source of the jerkiness, it would only happen once every 10 to 15 seconds. The clip being scrolled is about 4600 pixels wide.
*I just did a test with only 3 small photos and the "jump" still exists.