PDA

View Full Version : Preloader doesn't work



Wampiro-UHA
June 7th, 2009, 10:56 AM
I've tried to create a preloader in frame 1 which shows a small animation while the site loades. But it doesn't work as it actually loads the entire site before showing frame 1 which kinda takes the idea out of the preloader.

This is my code:
stop();
addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event) {
var bytesloaded=stage.loaderInfo.bytesLoaded;
var bytestotal=stage.loaderInfo.bytesTotal;
if (bytesloaded>10&&bytesloaded>=bytestotal) {
removeEventListener(Event.ENTER_FRAME, loading);
play();
}
}

outback
June 7th, 2009, 11:14 AM
try this...


this.addEventListener(ProgressEvent.PROGRESS, function(){
InstanceName_mc.play()
})
this.addEventListener(Event.COMPLETE, function(){
play()
})

Wampiro-UHA
June 7th, 2009, 11:27 AM
Then it does stall on frame 1 ,showing only the preloader animation and doesn't move on...

outback
June 7th, 2009, 11:41 AM
try

this.addEventListener(ProgressEvent.PROGRESS, function(){
InstanceName_mc.play()
})
this.addEventListener(Event.COMPLETE, function(){
nextFrame()
})

outback
June 7th, 2009, 11:45 AM
stop();

this.loaderInfo.addEventListener(ProgressEvent.PRO GRESS, loader)

function loader(e){
instance_mc.play()
}

this.loaderInfo.addEventListener(Event.COMPLETE, function(){
nextFrame();
})
sorry....forgot the loaderInfo

Wampiro-UHA
June 7th, 2009, 12:35 PM
It seems to do the same as my original code now.
It still doesn't show the preloader animation while loading. It still stalls.

It's weird because I've used the same code as for some of my ActionScript 2 sites (just converted to AS3) and they work...

snickelfritz
June 7th, 2009, 02:10 PM
AS3 has the document class which always loads in frame1.
Try loading the project into an empty host SWF.
(the only thing in the host swf is an instance of the loader class and associated progress/complete functions, and a small graphic or textfield for the progress indicator. The entire host swf is usually less than 10KB)

This should result in the preloader animation running from 0 - 100% loaded.
Lee Brimelow has good tutorial on this subject:
http://www.gotoandlearn.com/play?id=85

Wampiro-UHA
June 7th, 2009, 04:31 PM
That worked!

Thank you so much. Perhaps a bit annoying to have 2 movies, but it works!