firegambler
Technical User
hi,
actually i am trying to get a little insight into this whole object orientated thing. so i want to create a preloader which is pure code.
the problem is that the variable showing the percent loaded does not update, it stays at zero (at least that's what the textfield shows me); the variable that should show me the current frame of _root stays at 1 however the music that starts with frame 2 in my testfile can be heard.
finally the dynamically created textfields disappear when the film jumps to frame 2.
could anybody please correct my code and tell me why it didn't work?
i am not quite a newbie to flash but i am as far as it concernes object orientated programming...
thanks a lot![[thumbsup] [thumbsup] [thumbsup]](/data/assets/smilies/thumbsup.gif)
here is my code (which is positioned on the first frame of the root):
regards
actually i am trying to get a little insight into this whole object orientated thing. so i want to create a preloader which is pure code.
the problem is that the variable showing the percent loaded does not update, it stays at zero (at least that's what the textfield shows me); the variable that should show me the current frame of _root stays at 1 however the music that starts with frame 2 in my testfile can be heard.
finally the dynamically created textfields disappear when the film jumps to frame 2.
could anybody please correct my code and tell me why it didn't work?
i am not quite a newbie to flash but i am as far as it concernes object orientated programming...
thanks a lot
![[thumbsup] [thumbsup] [thumbsup]](/data/assets/smilies/thumbsup.gif)
here is my code (which is positioned on the first frame of the root):
Code:
_root.stop();
finishedloading = 0;
Preloader=new MovieClip();
MovieClip.prototype.makeTextfields=function(){
//textfield for percentage
_root.createTextField("percent",2,10,10,50,20);
percent.type="dynamic";
percent.variable="_root.percent";
percent.border=true;
percent.background=true;
percent.backgroundColor="0x00ffff";
//textfield for current (root)frame - just to see where we are while developing the code
_root.createTextField("WhereAmI",1,10,40,50,20);
WhereAmI.type="dynamic";
WhereAmI.variable="_root.whereami";
WhereAmI.border=true;
WhereAmI.background=true;
WhereAmI.backgroundColor="0x00ff00";
// textStyle
format=new TextFormat();
format.font="Arial";
format.bold="true";
format.size="16";
format.align="right";
format.color="0x000066";
//attach format to textfields
WhereAmI.setTextFormat(format);
percent.setTextFormat(format);
}// end of makeTextfields()
MovieClip.prototype.preload = function() {
total = getBytesTotal();
loaded = getBytesLoaded();
percent = Math.round(100*loaded/total);
_root.percent = percent+"%";
_root.whereami = _root._currentframe;
if (finishedloading==0) {
if (percent == "100%") {
_root.nextFrame();
finishedloading = 1;
} //end of if-condition
} //end of if-condition
}//end of preload()
Preloader.createEmptyMovieClip(MCPreloader,1);
MCPreloader.onLoad=makeTextfields();
MCPreloader.onEnterFrame = preload();
regards
