Hey i am messing around with a random bg preloader and it works fine when i test it in flash and hit cntrl+enter to simulate the dl. It shows the percent and draws a bar. But when i post it to my website and try it i either get NaN% or something like -19,000% but the page still loads up fine. Anyhelp would be greatly appreciated.
I’ve included the fla so you can see it work correctly.
And here’s a link that should show it going weird http://www.monkeymods.com/test
I’d strongly suggest adjusting your code so that the prototype is NOT nested within an onEnterFrame and if you change “this._width = Percent;” to “this._xscale = Percent;” you might get the effect you’re going for. But the reason nothing fades or scales-in is because you have the functions all hackneyed and misplaced (sorry).
Also, if you look closely at the load percent it will display a number in the negative thousands for a second or two when it first starts.
You could also get rid of about 1/2 of the code you have there.
I don’t know if you’re used to older versions of Flash (your programming style reminds of me Flash 5-ish programming), but with MX 2004, OOP, and AS2.0 I’d say you could clean things up a bit and optimize your code to be bullet-proof.
(As if that’s all not enough, I would also suggest using myText._text = “some text” instead of giving the textBox a var name and setting the var to equal the text – again, just more Flash 5 flare peeking through your code) :red:
No hard feelings newhope, I’m incredibly new to this and I’m breaking the first newb law by just reading random tuts and trying to train myself without a well based introduction. I just wanted to test this idea before i jumped into fully training myself. I’m pretty decent in C++ so i just figured i could cost on basic rules ;p
One question, do you know if i can have an if statement like if percent == NaN? cuz i’d like to just get rid of the possibilities of having NaN and -19000 by just replacing them with 0%. Thanks!
Seriously, it sounded cynical and snyde but I was only trying to make some coding suggestions.
Here are a few things you can try:
function checkData() {
var percent = textBox.text;
if (percent == -19000) {
// do something
} else if (isNaN(percent)) {
// do something else
} else {
// do another thing
}
}
I think there’s nothing wrong with your approach to self-teaching (it’s how I learned, actually). Screw those ill-defined newb laws.