onEnterFrame / while loop
- Started
- Last post
- 18 Responses
- mr_flaco
If I spawn an onEnterFrame inside a while loop, will it continue beyond the while statement and die when I tell it to from inside the onEnterFrame? Say the following was inside a while loop:
this.onEnterFrame=function(){
percent=(this.holder.getBytesLoa...
if(!isNan(percent)){
trace(percent+"% loaded");
}else{
trace("0% loaded");}
if(percent == 100){
delete this.onEnterFrame;
}
}Will it get to the delete, even after the while has completed?
- unfittoprint0
onEnterFrame should be avoided, it seems that the interval approach is advisable.
something like:
loadLoop = setInterval(function(){
if(this.holder.getBytesLoaded... && this.holder.
getBytesTotal()>10){
percent=100;
clearInterval(loadLoop);
} else {
percent = this.holder.getBytesLoaded()/thi...
};
}, 30)stop();
- unfittoprint0
oops______________*
loadLoop = setInterval(function(){
if(this.holder.getBytesLo
aded() == this.holder.getByt
esTotal()*100 && this.holder.
getBytesTotal()>10){
percent=100;
clearInterval(loadLoop);
} else {
percent = this.holder.getBytesLoade
d()/this.holder.getBytesT
otal();*100
};
}, 30)stop();
- mr_flaco0
Nice. Thanks so much.
- majman0
hey unfittoprint, why no onEnterFrame in this case?
just wondering what the logic is between using the two...
- unfittoprint0
interval is much more versatile, letting you control the refresh 'velocity' of the loop, can be function oriented and include specific function parameters.
- majman0
interesting, i'll have to start using it more often.
thanks for the info
- mr_flaco0
alright, 1 more thing unfit,
Ive got it tracing all of the correct values, but I get 0 every time for getBytesTotal even though Im looking at the jpg thats loaded! Does that value return to 0(presumably the size of the empty MC created) at some point?
- unfittoprint0
don't forget: only use setInterval AFTER calling the loadMovie method....
- mr_flaco0
of course!
Im still getting zero. The thing that is killing me is that it isnt undefined, its zero. If I call a trace for getBytesTotal directly after the load movie I get zero. I call it after everything has completely loaded, and zero. Frustrating.
- unfittoprint0
1 thing...offline Flash tends to compile everything immediately
so it will go from 0 to getBytesTotal() immediately...
try making that trace by forcing it within something like:
if(mc.getBytesLoaded()==mC.getBy... && mC.getBytesTotal()> 10){
trace(mC.getBytesTotal());
}good luck...
- mr_flaco0
will do; thanks for your help!
- nic0
What, it's 1:26 in the morning, and i'm talking actionscript, after booze!
*geekchat*
onEnterFrame, in practice is much more solid. There is a problem with setInterval ... when running setIntervals on different levels, remember that the setIntervals do not clear when you unload a level, and can continue running in another movie that you load in the same level. strange, but it can be a nightmare. You also have to deal with updateAfterEvent(), and if i can remember, setIntevals can only run as fast as the frame rate. (correct me if i'm wrong).
It's all a mess, but so many times, i've had to backtrack and make my intervals into onEnterFrames.
boom
- unfittoprint0
that's the booze talking.
been there. onEnterFrame is history...
ex.
simple setInterval:
myLoop=setInterval(function, speed)or
myLoop=setInterval(function(){
doThis();
}, speed)or [restricted form]
myLoop= setInterval(this, "function", speed, parameter1, parameter2, parameter3, parameter4, etc...)
OOP________ that's where it's at.
- nic0
I know how it's done. I'm just saying, if your gonna work on a project that loads swfs externally, it can be hard to keep track of loops, and making sure they stop when you want. I worked 2 months on a big project that all went wrong because of setInterVal. It's trendy, but no fun when you loose control, trust me.
- nic0
well, it all went wrong for a bit, and then it went right with onEnterFrame.
booze,booze,booze..
I'm outa here..
- xau0
Tell me this:
How do you get a 4 megabyte movie to stop loading... even when a new swf is *supposedly* loaded in it's place? And don't tell me to create a new movie clip (createEmptyClip) because the previous still loads in the background. Tell me that.
- xau0
*BUMP*
This is actually really bothering me. Anyone know what 2 do?
- mr_flaco0
post a new thread.