00:00
00:00
Newgrounds Background Image Theme

Someone gifted MetalSlayer69 supporter status!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS2 Preloader With Bar

213 Views | 3 Replies
New Topic Respond to this Topic

AS2 Preloader With Bar 2023-11-10 21:19:19


Hi again. I finally have motivation to get back into Flash creating. Why? Because an idea struck to me. The game I am working on is a visual novel. Here is my problem. I have the bar set up to 100 frames for loading progress purposes. The part I am stuck on is the aspect of loading the main content (main content: menu screen and everything else). I have looked up tutorials on Youtube, but some don't cater towards progress bars. I hate to rely on others for assistance because I prefer to find the solution myself, but sometimes help is a good thing. I hope I'm not bothering other people. Thank you in advance.

Below is my loader so that people know what is happening. (I know that the layers are locked, I unlocked them after this screenshot.)

iu_1111849_12827068.webp

Response to AS2 Preloader With Bar 2023-11-11 00:45:19 (edited 2023-11-11 00:48:29)


A quick, untested, throwaway solution...calculate the % loaded, and then go to that frame.

onClipEvent(enterFrame) {
    var percent: Number = Math.round(_root.getBytesLoaded() / _root.getBytesTotal() * 100);
    gotoAndStop(percent + 1);
}

+ 1 because the frames start at 1, not 0, and gotoAndStop expects a value greater than or equal to 1. If you have only 100 frames, you'll need to change the 100 to a 99, but I think it might be easier to just add an extra frame.


Also, if you're putting that code on the timeline itself instead of a movieclip, then change the

onClipEvent(enterFrame) {

to an

onEnterFrame = function() {

Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to AS2 Preloader With Bar 2023-11-11 09:12:23


At 11/11/23 12:45 AM, Gimmick wrote: A quick, untested, throwaway solution...calculate the % loaded, and then go to that frame.
+ 1 because the frames start at 1, not 0, and gotoAndStop expects a value greater than or equal to 1. If you have only 100 frames, you'll need to change the 100 to a 99, but I think it might be easier to just add an extra frame.

Also, if you're putting that code on the timeline itself instead of a movieclip, then change the
to an


That makes sense. I will test the code out when I get to my project. Once again, I'm sorry to be a bother. I'm still a noob at ActionScript.

Response to AS2 Preloader With Bar 2023-11-11 20:32:35


At 11/11/23 09:12 AM, ChanChanP wrote: That makes sense. I will test the code out when I get to my project. Once again, I'm sorry to be a bother. I'm still a noob at ActionScript.


No worries. We all started somewhere.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature