View Full Version : preload external swf with loadBar progress
vcorn4
January 22nd, 2004, 10:10 PM
hi anyone know how to to preloader for external swf which shows progress bar?
i've done it, but it doesn't work
if anyone has another way, plz help
i attach my fla
Thanks
claudio
January 22nd, 2004, 10:32 PM
Have you tested it onlice? Cause it wont work on your computer.
vcorn4
January 22nd, 2004, 11:02 PM
yes, i tested it with a 4 mb and 104mb swf in my computer, it shows that the progress bar always 100% full while the movie is loading
and i try upload to my website(online), the percentage text running(show progress), but the loadBar stay 100%...that's the problem, i also don't know why....have you done this before? did you use another way?
you can see my website, http://vcorn4.netpub.org/main.htm
you click the switch button at left bottom, you shall see the loadBar
claudio
January 22nd, 2004, 11:08 PM
Try removing all the code you have and using this one instead:
function preload(mc) {
this.createEmptyMovieClip("temp", 1000);
temp.onEnterFrame = function() {
var t = mc.getBytesTotal(), l = mc.getBytesLoaded();
if (t) {
var percent = Math.round(l*100/t);
if (l == t) {
loadBar._visible = false;
border._visible = false;
loadText = "";
this.removeMovieClip();
} else {
loadBar._width = border._width*l/t;
loadText = percent+" %";
}
}
};
}
clip.loadMovie("ff.swf");
preload(clip);
ez_stylin
January 22nd, 2004, 11:46 PM
shouldnt it be preload(mc); ?
claudio
January 22nd, 2004, 11:55 PM
Nope, mc is a parameter passed to the function. In this case, im passing the value clip to the function.
vcorn4
January 23rd, 2004, 12:03 AM
hi claudio, why do you use "this.removeMovieClip();"
since this one will remove the movieclip, i try it, it just shows a loadbar without even displaying the video
vcorn4
January 23rd, 2004, 12:05 AM
oh sorry, i try again, it seems i remove the clip instance, now it shows the video, but too fast, i can't see the loadBar, i'll try put it online
vcorn4
January 23rd, 2004, 12:11 AM
problem, claudio
the text 100% still there even after the movie play
vcorn4
January 23rd, 2004, 12:31 AM
now i put all movie clip in the same layer,
clip, loadBar,border now in the same layer, now i solve that the text isn't displayed anymore after the movie loaded
But back to main problem that the loadBar still didn't show any progress(always 100%)
claudio, if you have any fla that preload, could you post it?,this problem looks simple but really kills me
to see what i mean..you can go to http://vcorn4.netpub.org/main.htm and click the switch button at bottom left
vcorn4
January 23rd, 2004, 03:11 AM
hello friends,experts,everybody....helpppp
vcorn4
January 23rd, 2004, 06:29 AM
hi claudio,
actually both of our code works , but only for swf of type photo or anything except swf that contain embed video,
while the preloader in progress, the movie also start playing,
it streams, i don't know how to overcome this.
claudio
January 23rd, 2004, 11:16 AM
Are you dynamically loading a video on your external swf?
vcorn4
January 23rd, 2004, 11:20 AM
it is just one video in swf format(embeded video),
the ff-x.swf contain empty movie clip to load that external swf containing embeded video,
i try the preloader with swf contain photo, it works
but with swf containing video, while the preloader play, the movie already stream(play), what i did is just hide the movie until the preloader finish using clip._visible
but i know this is not a good way
claudio
January 23rd, 2004, 11:22 AM
Try:
function preload(mc) {
this.createEmptyMovieClip("temp", 1000);
temp.onEnterFrame = function() {
var t = mc.getBytesTotal(), l = mc.getBytesLoaded();
if (t) {
var percent = Math.round(l*100/t);
if (l == t) {
loadBar._visible = false;
border._visible = false;
loadText = "";
mc.play();
this.removeMovieClip();
} else {
mc.stop();
loadBar._width = border._width*l/t;
loadText = percent+" %";
}
}
};
}
clip.loadMovie("ff.swf");
preload(clip);
brian monkey
January 23rd, 2004, 11:41 AM
just so you know, you can test your preloader offline. after you hit test movie, hit ctr-enter and it should show progress. you can adjust the connection speed too.
hope you see what I am sayin,
brian
claudio
January 23rd, 2004, 11:42 AM
Nope, that wont work for dynamically loaded content.
brian monkey
January 23rd, 2004, 11:44 AM
I apologize, I didn't even pay attention to that.
,
brian
claudio
January 23rd, 2004, 11:45 AM
Dont worry brian ;)
vcorn4
January 23rd, 2004, 12:00 PM
as i've seen in your code, i replace _root.clip._visible = 0 in my code with _root.clip.stop();
and _root.clip._visible = 1 with _root.clip.play();
it works,
Thanks claudio
vcorn4
January 23rd, 2004, 12:01 PM
but i must leave the first keyframe of the external swf(video) blank
vcorn4
January 23rd, 2004, 12:02 PM
Thanks a lot:)
vcorn4
January 23rd, 2004, 12:16 PM
oopss...claudio
funny things happen
guess what,now my button to stop and play inside the external swf(video) won't work..it keeps on playing.
and one more...it has no sound
claudio
January 23rd, 2004, 12:17 PM
Can you post the code on your external swf?
vcorn4
January 23rd, 2004, 12:20 PM
i can't post fla since it is too big
it has two layer,
one for the video and one for button,stop and play buttons
the code is just on(release){stop();} and on(release){play();}
respectively,
and for the two layer the first keyframe is blank
vcorn4
January 23rd, 2004, 12:21 PM
sorry..forget to tell you that when i play the external swf individually, it works normally
but when i play the main that load that external swf, it has no sound and the button won't work
claudio
January 23rd, 2004, 12:24 PM
How big is the file?
vcorn4
January 23rd, 2004, 12:25 PM
4.9mb
claudio
January 23rd, 2004, 12:28 PM
Cant you upload to some free web server so i can download it?
vcorn4
January 23rd, 2004, 12:28 PM
i think i've found a hint,
i use clip.onEnterFrame = null;
after byte_loaded == byte_total;
when i insert trace("anam");
it keeps on tracing anam eventhough it finish loading
so the script that call play(); keep running
vcorn4
January 23rd, 2004, 12:34 PM
hi claudio,
i copy and paste your code, your style that use a temp clip and remove it, works fine, it remove the whole temp clip including the onEnterFrame function,
but i use this
onClipEvent (enterFrame) {
_root.loadBar._visible = 1;
_root.border._visible = 1;
byte_loaded = Math.round(this.getBytesLoaded());
byte_total = Math.round(this.getBytesTotal());
percent = byte_loaded/byte_total;
_root.clip.stop();
_root.loadBar._width = Math.round(percent*100)+5;
_root.loadText = Math.round(percent*100)+"%";
if (byte_loaded == byte_total &&byte_total!=0) {
trace("anam");
_root.clip.play();
_root.loadBar._visible = false;
_root.border._visible = false;
_root.loadText = "";
delete this.onEnterFrame;
}
}
could you tell me...why the script still run the trace("anam") even after i do delete this.onEnterFrame???
claudio
January 23rd, 2004, 12:37 PM
Because you are using a static event handler, and it cannot be deleted or emptied.
If you use my code, the video plays correctly?
vcorn4
January 23rd, 2004, 12:42 PM
yes your code works correctly
for my code i need to add
if(!loaded) inside the onClipEvent(enterFrame)
and set loaded to true once the byte_loaded == byte_total
then it will be correct.
but i think yours is more efficient, since mine still keep on checking if(!loaded) statement even though the movie finish loading because you said that static event handler can't be deleted
vcorn4
January 23rd, 2004, 12:45 PM
oops...forget to say:
Thanks
claudio
January 23rd, 2004, 12:49 PM
Welcome =)
Wow, after 3 pages i think we are done by now..
vcorn4
January 23rd, 2004, 12:53 PM
yeah, now 100% sure it's done:)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.