# \[FMX\]Moving a mc a certain distance while preloading

**URL:** https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292
**Category:** Uncategorized
**Created:** [August 13, 2004, 7:04am UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292 "2004-08-13T07:04:44Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 7:04am UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/1 "2004-08-13T07:04:44Z")

</div>

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

```auto
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

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 9:08am UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/2 "2004-08-13T09:08:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 11:30am UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/3 "2004-08-13T11:30:01Z")

</div>

Something like

```auto
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(-:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 11:43am UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/4 "2004-08-13T11:43:00Z")

</div>

Hi scotty,

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

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 12:02pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/5 "2004-08-13T12:02:51Z")

</div>

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

```auto
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(-:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 12:18pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/6 "2004-08-13T12:18:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 12:30pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/7 "2004-08-13T12:30:17Z")

</div>

My bad:stunned:  
The easeLoad function should read:

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

```

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

scotty(-:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 1:08pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/8 "2004-08-13T13:08:35Z")

</div>

lol 🙂 You know what happen now 🙂 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?

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 1:19pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/9 "2004-08-13T13:19:13Z")

</div>

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

scotty(-:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 1:31pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/10 "2004-08-13T13:31:08Z")

</div>

🙂 Here it is

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 1:47pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/11 "2004-08-13T13:47:09Z")

</div>

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

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

```

scotty(-:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 1:54pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/12 "2004-08-13T13:54:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![newhopekenny](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/newhopekenny/32/317_2.png) [@newhopekenny](https://forum.kirupa.com/u/newhopekenny)
#### Post date: [August 13, 2004, 2:00pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/13 "2004-08-13T14:00:21Z")

</div>

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](http://www.actionscript.org/tutorials/advanced/Tween-Easing_Classes_Documented/index.shtml)

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 13, 2004, 2:02pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/14 "2004-08-13T14:02:51Z")

</div>

Welcome, dboers:thumb:

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 13, 2004, 2:08pm UTC](https://forum.kirupa.com/t/fmx-moving-a-mc-a-certain-distance-while-preloading/119292/15 "2004-08-13T14:08:34Z")

</div>

> [@newhopekenny](#):
>
> 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](http://www.actionscript.org/tutorials/advanced/Tween-Easing_Classes_Documented/index.shtml)

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