[FMX]Moving a mc a certain distance while preloading

How can I make a movieclip move over a certain distance during the preloading process. This is my preloader code:

this.onEnterFrame = function(){
	  tb = this.getBytesTotal();
	  lb = this.getBytesLoaded();
	  percent = Math.round(lb/tb * 100);
	  this.preloader.per.text = percent;
	  this.preloader.bar._xscale = percent;
	  if(lb >= tb){
			delete this.onEnterFrame;
			nextFrame();
	  }
}
stop();

Thanks in advance

The distance should be the same as the width of the preloader bar

Something like

var startX = yourmc._x;
this.onEnterFrame = function() {
	tb = this.getBytesTotal();
	lb = this.getBytesLoaded();
	percent = Math.round(lb/tb*100);
	this.preloader.per.text = percent;
	this.preloader.bar._xscale = percent;
	yourmc._x = startX+percent;
	if (lb>=tb) {
		delete this.onEnterFrame;
		nextFrame();
	}
};
stop();

?

scotty(-:

Hi scotty,

Thanks a lot. That is working fine. One last question ! Is it also posible to make that movement easing?

LOL, off course [size=1](I hope)[/size]

var startX = yourmc._x;
this.onEnterFrame = function() {
        tb = this.getBytesTotal();
        lb = this.getBytesLoaded();
        percent = Math.round(lb/tb*100);
        this.preloader.per.text = percent;
        this.preloader.bar._xscale = percent;
        easeLoad(percent);
        if (lb>=tb) {
                delete this.onEnterFrame;
                nextFrame();
        }
};
function easeLoad(percent){
	lc._x=startX+(percent-(percent-lc._x)/1.1);
}
stop();

scotty(-:

:h: Now it isn’t moving anymore. What do you think is wrong?

My bad:stunned:
The easeLoad function should read:

function easeLoad(percent){
        yourmc._x=startX+(percent-(percent-yourmc._x)/1.1);
}

where yourmc is the instancename of…your mc:lol:

scotty(-:

lol :slight_smile: You know what happen now :slight_smile: This is for a site promoting motorcycle tours in Thailand, and the motorbike I use for this looks like the fastest motorbike on earth. It move out of the screen from left to right like hell.

I cant find out what is wrong?

LOL, it worked here…
Can you post your fla?

scotty(-:

:slight_smile: Here it is

That’s one fast bike:lol:
I’ve made it a Solex;)
change the easeLoad function in this

function easeLoad(percent) {
	var newX = startX+percent;
	motorMC._x = newX-(newX-motorMC._x)/1.1;
}

scotty(-:

Great move scotty :thumb:, but to me it looks more like a Puch :hugegrin:It’s working great now! Thanks

Why not just use the built-in easing functions? You’d have a smoother effect, and more variants to choose from:

http://www.actionscript.org/tutorials/advanced/Tween-Easing_Classes_Documented/index.shtml

Welcome, dboers:thumb:

I’m quit happy how it is right now, but thanks anyway for the link :slight_smile: