View Full Version : Simple code problem!
kev
December 12th, 2003, 11:19 AM
Hi, i have a simple problem, that should work!
Here is the site - monoequip (http://www.monoequip.com)
on the home page is a news scroller which has a preloader!
The preloader is on one scene (loader) and the content is in another (content)
on the first frame (loader)I have this code:
total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded ("loader", 30) {
gotoAndPlay ("content", 1);
}
So if the user has veiwed this before then the flash should skip the preloader part and go straight to the (content) scene! but it does not, it just plays through the (loader) scene and then plays.
If you to the site above, you see the percentage loader appear and then the content should appear once loaded, this works fine. try going to any link and then go back to the homepage and you will see what i mean!
Can someone help out!
Thanks in advance
Digitalosophy
December 13th, 2003, 03:49 PM
well you can make your IFFramesLoaded on frame 1, if not loaded go to frame 2 where your preloader script will be
edit: btw do you mind me asking why your naviagtion is in flash? honestly dude, i've found out that if you dont need flash then you shouldn't use it, ya know? you should think about making your nav using css.
nice site :)
kev
December 15th, 2003, 04:54 AM
Hi, Digitalosophy. I have the IFFramesLoaded on frame 1 already, but it does not seem to work! Any ideas why this don't work? Maybe, the frame is not being read in time, maybe I need to add a loop for it or something!
I'll let you know.
The navigation is in flash because the 'Directors' with this company think it's cool! i aint going to argue that one, i just did it. I am not proud of it :) but hey it pays the bills :)
CSS is one of the big steps I want to implement to this site, as I took it over from another designer, where every page was just plain HTML, and it's a pain to update or add new pages in it's current state!
Thanks
Kev
kev
December 15th, 2003, 08:04 AM
I can't get this to work, maybe it's the scenes. i never usually use scenes, so this might be the problem!
I'll try this all in one and see what happens!
kev
December 15th, 2003, 08:43 AM
Well it ain't the scenes :)
Anyone got a simple example of a preloader, but with a check first to see if the contents have loaded, then if they have previously been loaded then skip the preloader alltogether?
thanks
kev
Digitalosophy
December 16th, 2003, 01:47 AM
hey man sry, i didn't notice you replied to this thread.
i can't post the fla, you won't be able to open it in flash 5.
i have 2 scenes.
in scene 1 frame 1
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBarFill._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}
in scene 1 frame 2
gotoAndPlay(1);
this works fine for me, it should for you as well.
Digitalosophy
December 16th, 2003, 01:48 AM
hey man sry, i didn't notice you replied to this thread.
i can't post the fla, you won't be able to open it in flash 5.
i have 2 scenes.
in scene 1 frame 1
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBarFill._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndPlay(3);
}
in scene 1 frame 2
gotoAndPlay(1);
this works fine for me, it should for you as well.
kev
December 16th, 2003, 03:54 AM
Thanks Digitalosophy, but I don't think I explained myself very well. I have a preloader that works fine, like the one you have kindely posted! The preloader AS is on frame 5 & 6.
What I need on frame one is another piece of code which checks to see if this movie has been loaded before, if it has then go straight to the next scene and skip frame 5 & 6 altogether.
Something like this I was thinking:
if (_framesloaded > 0 && _framesloaded == _totalframes) {
gotoAndPlay ("contents", 30);
} else {
gotoAndPlay ("loader", 4);
}
Hope you get me, like I said if you check the url in the first post and refresh the home page, you'll see that the preloader appears for a few seconds, even though the movie has already loaded! just want to skip this.
Thanks
Kev
Digitalosophy
December 17th, 2003, 02:59 PM
ahh yes sry now i understand. something like this should work for you.
ifFrameLoaded ("Scene 2",30) {
gotoAndPlay ("Scene2", 1);
}else{
gotoAndPlay("preloader");
}
kev
December 18th, 2003, 12:33 PM
Thanks Digitalosophy, works like a chram :)
Take care
Digitalosophy
December 18th, 2003, 12:37 PM
gr8
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.