Why it does not work smoothly?
I tried using a small image (500px width), but it’s also jerky animation
var loader:Loader = new Loader();
loader.load(new URLRequest("http://cevek.ru/img0.gif"));
// http://cevek.ru/img1.gif 500px width
addChild(loader);
var img_x = 0;
stage.frameRate = 100;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event){
img_x++;
loader.x = -1*img_x;
}
Other variant
var loader:Loader = new Loader();
loader.load(new URLRequest("http://cevek.ru/img3.gif"));
addChild(loader);
var img_x = 0;
stage.frameRate = 25;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event){
img_x+=4;
loader.x = -1*img_x;
if (img_x > 100)
img_x = -500;
}
You are using a picture that is way too large for the Flash Player to handle. It’s not 500 pixels, but 20000 pixels wide! If that has to be scaled down at runtime, too, it is really no surprise the animation is jerky…
You should scale down your picture in Photoshop (or any comparable program) and use the scaled-down version for your animation – all your problems will go away.
If you need the full picture width for a larger view, cut the picture into smaller parts ( I would suggest no more than 100 pixels width ), and set all the ones that are outside of the visible area to
visible=false;EDIT
Also, you might want to consider using an event listener to wait for the image to be fully loaded, before you start the animation.
More EDIT
Use a Tween, or better yet, use TweenLite.