Skip to main content
Known Participant
November 10, 2007
Question

Preloader not working in externaly loaded swf (HELP!)

  • November 10, 2007
  • 4 replies
  • 306 views
Hi.

I have posted this before but could not get the method suggested to work.
I have an swf ("myCarMovie") that opens within an empty movie clip ("picHolder") that is on the main timeline of my movie. "myCarMovie" is triggered from a button on a thumbnailer that opens it within "picHolder". All works well until I add the preloader that features a progress bar and percentage loaded.

I have placed the progress bar at the start of "myCarMovie". When I test "myCarMovie" on its own it is fine but not when I publish and run the whole movie. What happens is that it shows just the loadbar graphic at 100% length and does not move to frame 2. It is stuck on the loadbar graphic.
Obviously I started looking at _root in the script.

I have included the script for the preloader below if anybody wants to make a suggestion and give me a cure!!


Thanks



onClipEvent (load) {
var origW = _root.loadbar._width;
var newW = _root.loadbar._width;
var moveX = _root.loadbar._x-(_root.loadbar._width/2);
}
onClipEvent (enterFrame) {
_root.percent = int((_root.getBytesLoaded()/_root.getBytesTotal())*100);
_root.txtPercent = _root.percent+"%";
_root.loadbar._width = Number(_root.percent);
_root.loadbar._x = moveX+_root.loadbar._width/2;
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
_root.gotoAndPlay(2);
}
}
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
November 10, 2007
you're welcome.

when you test myCarMovie without loading it into another swf, _root refers to the main timeline of myCarMovie. which is what you want to preload. but when you load myCarMovie into another swf (in _level0), _root will refer to the main timeline of the loading swf, NOT myCarMovie.

one remedy, is to lock all references to _root used in myCarMovie to the main timeline (= this when that code is attached to your main timeline) in myCarMovie. that's what the code i suggested is doing.
tacbobAuthor
Known Participant
November 10, 2007
It doesnt show when I upload!!

Thanks kglad
tacbobAuthor
Known Participant
November 10, 2007
Marvellous Kglad...marvellous!!

Thanking you! What exactly is the script doing?
It works but for some reason, when I preview it in the Simulate Download, for a fraction of a second you see the progress bar at 100%. Will I see this when I upload the file?

Thanks again
kglad
Community Expert
Community Expert
November 10, 2007
in your external swf myCarMovie add the following to the first line of your first main timeline frame: