The Little Guy Posted October 11, 2008 Share Posted October 11, 2008 this is more of ActionScript Math question, so here is my prob: I am loading a video, and I have a: - preloader - timeLine - scrubber This converts the loaded bytes of the totoal size to a percentage: var btsLoaded:Number = Math.round(my_ns.bytesLoaded/my_ns.bytesTotal * 100); what I need to do, is get the loaded amount, get the width of the timeLine, and figure how wide the preloader should be. So... 100% loaded needs to equal the width of the timeLine 50% loaded needs to equal the half the width of the timeLine and so on... this works the same as YouTube's video loader, and all the others. timeLine width: controlsBG.timeLine.vidLen._width // timeLine width Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/ Share on other sites More sharing options...
JasonLewis Posted October 12, 2008 Share Posted October 12, 2008 Wouldn't you do the same thing as the percentage but multiply it by the width of the timeline? Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663079 Share on other sites More sharing options...
corbin Posted October 12, 2008 Share Posted October 12, 2008 Basic concept of a percentage is x/100. x% means x/100 (in simple terms). So, when you're taking Math.round(my_ns.bytesLoaded/my_ns.bytesTotal * 100); to make it a percent, you need to divide it by 100 again to get a usable number for multiplication. Why do so many people have problems with percentages..... Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663178 Share on other sites More sharing options...
The Little Guy Posted October 12, 2008 Author Share Posted October 12, 2008 Im confused, do you happen to have an example? Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663196 Share on other sites More sharing options...
corbin Posted October 12, 2008 Share Posted October 12, 2008 You're confused?!?!??!?!?!?! No offense, but.... What?!?!?!?! Enough with the rudeness and way over use of question/exclamation marks now: w = round(l/t*b) Where w = width representation (in px) of finished, l = loaded, t = total, b = total width of bar. Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663205 Share on other sites More sharing options...
The Little Guy Posted October 12, 2008 Author Share Posted October 12, 2008 If this is what you mean: ratio = Math.round(my_ns.bytesLoaded/my_ns.bytesTotal*controlsBG.timeLine.vidLen._width); controlsBG.timeLine.loadedAmt._width = ratio; It doesn't work, it says that if it is 100% loaded, then it is only is 50% of the bar wide. Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663208 Share on other sites More sharing options...
JasonLewis Posted October 12, 2008 Share Posted October 12, 2008 That's exactly what I said corbin, isn't it? Try this TLG: ratio = Math.round((my_ns.bytesLoaded/my_ns.bytesTotal) * controlsBG.timeLine.vidLen._width); controlsBG.timeLine.loadedAmt._width = ratio; Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663225 Share on other sites More sharing options...
corbin Posted October 12, 2008 Share Posted October 12, 2008 That's exactly what I said corbin, isn't it? Try this TLG: ratio = Math.round((my_ns.bytesLoaded/my_ns.bytesTotal) * controlsBG.timeLine.vidLen._width); controlsBG.timeLine.loadedAmt._width = ratio; Never said that's not what you said ;p. Just gave him a concrete example like he asked. (Also, I was explaining that x percent is not what he should be multiplying by. He should multiply by x%/100 or the original ratio ;p) Quote Link to comment https://forums.phpfreaks.com/topic/128021-percent-to-pixels/#findComment-663402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.