ok, looks like it’s probably one of the most usual problem people experience, they’re tons of posts about it, yet I haven’t been able to find one with an answer…
You make a preloader like in Kirupa’s tutorial with something like:
That preloader “technically” works, but for me, as well as many others from what I could read on these forums, it is rendered pretty much useless by the fact that Flash won’t enter Frame 1 (where the preloader is) until the whole library stuff referenced within the Linkage property panel is loaded. Ideally, if I could select “export to frame 2” in the Linkage panel, my problems would be solved… My question is: what’s the usual work around this shortcoming in Flash? I tried to put the preloader in a different scene (I hate scenes…) but it seems the “export” thing still loads the externally linked library items in the 1st frame of the first scene…
The answer is probably somewhere on here already but I don’t feel like going into every thread called something like: “preloader, please help”… I need something specifique concerning the export to first frame thing related to the preloader issue. Thx for any help…
Now I haven’t tested this yet… But by looking at the tutorial that kirupa provided and mingling it with the effect you wnat… It should work… Now… Just delete eveything off of the first frame that has anything to do with the animation you want to load up… And do it that way…
The code I provided is meant to be placed in the first frame’s actions… Not a movie clip’s actions btw…
You might also wanna change “something” before _root.something.kirupatxt to the actual instance name… Or just _root.kirupatxt… Whichever…
I appreciate you tryin to help but see, the problem here, is not the preloader code (on a clip or frame…) it’s the fact that the Flash player will load the content of the library that is linked from the linkage panel with the “export in first frame” checked, before it even gets to the first frame, making the preloader code useless… I need to find the work around for this Flash behaviour. Whatever code you put in Frame 1 doesn’t even matter at this point…
As a side note, I can’t “Just delete eveything off of the first frame that has anything to do with the animation you want to load up” because that would translate to unchecking all the “export to first frame” in the linkage panel and the movie doesn’t work anymore if I do that… (that’s the first thing I tried, not knowing exactly what that checked box was for…)
Thx though!
The problem, as you have guessed, is that flash loads exported in the first frame items before the rest of the movie, hence before the preloader.
You have 2 solutions:
You use an empty swf in which you load your movie, and you control the load from that swf.
You don’t export in the first frame, but you’ll have to put all the attached symbols somewhere on the scene at some point, because you can’t attach a clip if it has never been present on the stage.
That’s what I thought… thx! So I have one more question: when I load a movie, lets call it mov1, into another called mainMov. My mov1 has many reference to _root and doesn’t seem to work anymore. From what I read somewhere, it seemed to me that _root would be for the timeline of the movie it’s in. I was wrong right? looks now that the _root in mov1 refers to the _root of mainMov when it’s loaded in it. Am I right? If yes, you know a quick fix? Or I need to go through all my code replacing the absolute paths to relative ones?
first of, sorry to bother you with this beginner stuff but I got pretty much the whole site done and I’m stuck because of this preloader not preloading… I tried to figure out what 's wrong but I think I’m just stupid and I give up…
So, from what Sbeener tells me, if you load a mov1 into a mainMov with loadMovieNum (“mov1.swf”, 5) it will load into _level5 and all the “_root.” stuff will refer to its own root (or _level5 of the .mainMov). I didn’t think it did because, when doing that, all my embeded fonts desappeared. But since I got so many problems since I started this project with those fonts, I’ll assumed it’s just some kinda strange behaviour. embedding the fonts again in the mainMov solved the font issue. But I don’t want to use the “export to first frame” obviously, that would defeat the purpose of this mainMov.
So, that’s the idea of what I think I have to do:
put a preloader code/animation on frame 1 along with the loadMovieNum
then put the fonts on stage on frame 2 so it loads without the “export to 1st frame”
start the movie with something like _level5.gotoAndPlay(2); (keeping the 1st frame of mov1 empty so nothing shows)
I tried a bunch of different codes based on the kirupa tutorial and the info I could get from those forums… But, as I mentioned above, I’m stupid, didn’t work, and I need help. The friend I’m making the site for is starting to think I’m full of … cause I told him the site was pretty much done but I’m not putting it online… help!!
this is a problem. looks like a flash shortfall. seems as though when you load in a movie, it loses any assets that were exported from the library. not cool.
i think we can find a work around though. seems that if you use an asset which has been exported for runtime sharing you then have access to all of the exported symbols from the external clip.
strange behaviour indeed. but good because now we can make your movies work!
so in mov1, right click (command click for a mac?) a clip in the library and choose linkage. select ‘export for runtime sharing’ and put the url where this clip will reside in the box marked ‘URL’. i think that relative urls are valid so ‘./mov1.swf’ should work.
drag that clip from the library onto the stage (it must exist on the stage for this to work) of mainMov.fla. the clip will add itself to mainMov’s library. checking the linkage on it should show a check in the ‘import for runtime sharing’ checkbox and the same url in the ‘URL’ text box.
when i did this, all of mov1’s assets became available, including the fonts, which meant that embeded fonts in dynamic text boxes worked in both movies from the single source - even though i didn’t export the font for sharing, just for actionscript.
Sbeener:
ok, cool… I think I get what you’re saying and I’m gonna test it out now, one more question though (I would search for the answer instead of just asking normally but lack of sleep and deadline are working against me here… ;): what’s the conditional statement for the preloader with levels? I’m kinda confused about when to load the the mov1 in mainMov. I’m assuming you cant use the getBytesTotal until you started loading the mov1 but I’m not sure of anything anymore at this point… :-\
If you could just write me the basic “if else” statement and it’s relative position with the loadMoveNum, it would save me some precious time…
Also, I forgot to tell you: I used your find/replace proto I found somewhere here to get the URL of some ext .swf subCategory files in my mainMov. I used that to remove the spaces from the array elements to convert them easily to URLs. Very cool!
i’m a little unsure of what you mean… conditional statements? you mean for checking if it’s loaded?
if mainMov is just for the preloader, something like this in frame 1 should do the trick:
loadMovieNum("mov1.swf",1);
_root.onEnterFrame = function(){
var t = _level1.getBytesTotal();
var l = _level1.getBytesLoaded();
if(t && t == l){
this.onEnterFrame = null;
}
// code to drive preloader...
}
thx again… the linkage thing works like a charm… How the hell did you find that out?
But… there is a BUT…
My preloader still doesn’t work
so here’s what I’m trying to get:
the usual dynamic text giving you the % loaded w/ a nice little progress bar, and then mov1 plays. Very simple… But I’m still confused about the whole level thing…
So, if you could be so kind to talk to me as if I were a retarded actionscripter wanna be, and explain the whole process?
So I have
loadMovieNum("mov1.swf",1);
_root.onEnterFrame = function(){
var t = _level1.getBytesTotal();
var l = _level1.getBytesLoaded();
if(t && t == l){
this.onEnterFrame = null;
}
???
}
on the 1st (and only) frame of mainMov and then a preloadMov looping on stage with some animation…
I guess I can’t figure the ??? part. I’m not sure I’m getting what your code does, I thought I did… First I tried replacing the ??? with something that would update a dyn text field with the bytesLoaded but did not work…
I promise, when I’m done with that one, I’ll stop bothering you (for a while)…
i’m assuming that the assignment to t and l is self explainatory so i’ll just skip right to the if statement.
if(t
if t returns true. there’s a brief second where the movie hasn’t started loading yet so t and l both equal undefined or false (i’m not sure which). so then the t == l check returns true and we think that the movie has finished loading when actually it hasn’t started.
&& t == l){
that’s pretty clear right? if total == loaded then everythings good. we can rely on this because we know t is returning a good value from the first half of the if statement.
this.onEnterFrame = null;
cancel this function. no reason to keep it running once we’re done.
}
// other stuff
you were correct to put your code here. hard to know why it wasn’t working. try tracing the values here to make sure everything’s working like it should. i didn’t try this code out so there might be something messing it up. try something like:
trace(“t:”+t+"
l:"+l+"
");
that will let you know what’s getting returned for your t and l values.
ok, this is not working… Can’t figure out what I’m doing wrong…
I have
loadMovieNum("main.swf", 1);
_root.onEnterFrame = function() {
var t = _level1.getBytesTotal();
var l = _level1.getBytesLoaded();
if (t && t == l) {
_level1.gotoAndStop(2);
this.onEnterFrame = null;
}
myTxt = "loading ("+l+"/"+t+")";
};
in a 1 frame movie with the above action on a layer named “actions” and a dyn text box with the variable myTxt assigned to it on another layer. The “main.swf” is a 2 frame movie with the 1st frame empty with a stop(); action and all the content on frame 2.
when I publish that
I get an empty screen for the whole loading time and then the “loading 107248/107248” text appears at the same time as the main.swf
I don’t get it…