dboers
August 13, 2004, 7:04am
1
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
system
August 13, 2004, 9:08am
2
The distance should be the same as the width of the preloader bar
system
August 13, 2004, 11:30am
3
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(-:
system
August 13, 2004, 11:43am
4
Hi scotty,
Thanks a lot. That is working fine. One last question ! Is it also posible to make that movement easing?
system
August 13, 2004, 12:02pm
5
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(-:
system
August 13, 2004, 12:18pm
6
:h: Now it isn’t moving anymore. What do you think is wrong?
system
August 13, 2004, 12:30pm
7
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(-:
system
August 13, 2004, 1:08pm
8
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?
system
August 13, 2004, 1:19pm
9
LOL, it worked here…
Can you post your fla?
scotty(-:
system
August 13, 2004, 1:47pm
11
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(-:
system
August 13, 2004, 1:54pm
12
Great move scotty :thumb:, but to me it looks more like a Puch :hugegrin:It’s working great now! Thanks
system
August 13, 2004, 2:00pm
13
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
system
August 13, 2004, 2:08pm
15
I’m quit happy how it is right now, but thanks anyway for the link