-
Percent preloader for dynamic text
Hi,
I load my text trough a loadvariable action to a blank movie to store them.
I would like to have a preloader to for all those variables.
I know only onclipevent (data) which is not what I need and the usuals "percent" loaders do not work...
Does someone know how to proceed?
Sylvain
u-lounge.net
-
Hi,
you cannot have a percent preloader on variables...
Musicman
-
What about using the LoadVars functions, does anyone have an example of this workin. And is this only possible in flash 6?
-
basically, what we need is :
1/ load variables in a movie clip (ok, we all know how to do that...)
2/ that's the problem : get the total bytes and the bytes loaded to preload those variables and get percents or whatever.
_getbytesloaded and _getbytestotal on this movie clip, you would say...
yes... but no, it does not work... or a way I do not know.
Does someone know?
-
Muiscman is right, you cant use the MovieClip functions of getBytesLoaded etc. Although i think you can use the LoadVars object and its functions, its just that im not sure how to implement it.
-
you're right durks!
It seems the loadvars functions are the good way (the only...) to make it !
there are getbytesloaded and getbytestotal methods... uhm...
thanks durks !
www.u-lounge.net
-
if you get anything up and running i would be interested in seeing what youve done, cheers
durks@creativeoutlet.co.uk
-
Hi,
if you load a movie, the very first bytes contain information about the total bytes to expect.
If you load variables, this information is usually absent (a webserver may decide to add it to the data)
Musicman
-
hey
I think this relates to something I was thinking about, but I'm not sure. Could a preloader be created for an external swf being loaded into a movie when the swf itself has no preloader?
It seems to me the answer to this would be the same as the answer you're looking for. Am I right? If so, I'd really like to know anything you find out.
Thanks and good luck.
-
Hi Osnoff,
you can create a preloader sitting in your main movie and monitoring a movie that loads in.
There is an issue similar to the missing size for variables: right after the request is sent (before the first few bytes of the movie are available) there is no total size. Depending on your particular player, the bytestotal etc. functions and properties may return the undefined value or a negative number; so if you use a bytesloaded==bytestotal type test it may do the wrong thing. Checking that the variables are positive numbers helps a lot....
Musicman
-
hey
I've modified the code on my loading bar to target the movie loading in. It returns the bytes total as 12.
This isnt a negative or undefined like you said, but it's definatly not right.
I don't know any type of preloaders other than the BytesLoaded==BytesTotal
What other ways could it be done?
My continuous thanks.
-
this is all a simple kilobytes preloader is. just place this code on a move clip. and inside that movie clip place a dynamic text box with the variable name "percent_loaded"
onClipEvent (enterFrame) {
//
// this if statement does the preloading as long as the variable 'loaded'
// is false. when the swf you are preloading loads, it changes the 'loaded'
// variable to true. Other wise the last statement in this code would continually
// tell your loaded swf to gotoAndPlay frame 10
if (loaded != true) {
//
// variable containing the file size of the swf on level5
bytes_total = int(_level5.getBytesTotal());
//
// variable containing the bytes loaded
percent_loaded = int(100*_level5.getBytesLoaded()/bytes_total);
//
// if the percent_loaded variable equals 100, then tell the
// swf on level5 to play
if (percent_loaded == 100) {
_level5.gotoAndPlay(10);
}
}
}
this code does a preloader for a movie loaded in on level5, you can load your swf in at any level, remeber to change this to what ever level you load your swf to.
in the swf that you load in, place a stop command in the first frame so that it doesnt play until it has loaded.
the code above tells your loaded swf to goto and play frame 10 once it has fully loaded, again you can change this to any frame number or lable you want. On the frame where your loaded swf begins playing you need to place this code to tell the preloader to stop checking the bytes loaded
_level0.preloader:loaded = true;
hopefully this should sort you out
still havnt solved the original question though of getting a preloader for the bytes loaded when you load a text file into a textbox.
-
Thanks. That's gotten me a lot farther than I was.
There seems to be a problem, however.
The entire movie preloads while on frame 0, so the loading bar doesn't have a chance to display anything other than 100%.
Do you know a way this could be happening?
I was forced to modify your code slightly to fit my loading bar but it kept the basics so it should still work. Perhaps if I were to send you the .fla you would be able to see a problem?
I don't know if my email is on here so its:
sentient_spacedust@hotmail.com
If you want to help just send me an email and I'll send you the .fla.
Thanks in advance.
-
i tell you what ill do a quick example and ill email you the files.
-
Hi durks,
a bit of warning: whenever you load anything but the main movie, there is a short moment where the request has been sent but the size of the movie is not yet known.
Some players return undefined for both total and loaded bytes, others return -1. The latter case may lead to detect an unreal 100%.
So far preloaders doing nothing unless the tota bytes are positive have worked fine for me
Musicman
-
thanks for that point. the way i get round it is to have the movie that i load in to pass a variable to the preloader mc which is on another level, which allows it to get the byte values.
by the way did you develop a preloader that gets the bytes loaded values when you load a txt file into a dynamic text box?
-
Hi
I still believe that it is not possible ....
Musicman
-
well ive persisted and i think ive managed to do it.
place this code on a movie clip, inside the movie clip have a dynamic text field with the variable name of 'text_box'
have a text file in the same directory, and in that text file have a variable called information.
onClipEvent (load) {
myLoadVars = new LoadVars();
myLoadVars.onLoad = function(success) {
text_box = myLoadVars:information;
};
}
on (release) {
myLoadVars.load("data.txt");
}
onClipEvent (enterFrame) {
bytes_total = myLoadVars.getBytesTotal();
bytes_loaded = myLoadVars.getBytesLoaded();
percent_loaded = int(100*bytes_loaded/bytes_total);
loader.gotoAndStop(percent_loaded);
}
this is only possible in flash6 i think
-
Hi,
I will try it later, but most scripts do not allow the preloader to know the total size before the data is fully loaded...
Musicman
-
Senior Member
OK here is the FLASH MX solution.
Just in case you still did not get this to work.
This should work for your text variables!
I have used it before.
FRAME 1
my_data = new LoadVars();
my_data .load("data.txt");
Frame 2
total = my_data .getBytesTotal();
loaded = my_data .getBytesLoaded();
if ((prozent = parseInt(loaded/total*100))>100){
prozent = 100;
}
_root.bar._xscale = prozent;
// this is your advancing preloader bar movie
FRAME 3
if (my_data .loaded) {
gotoAndPlay(4);
} else {
gotoAndPlay(2);
}
Best wishes
http://www.advance-media.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|