views:

678

answers:

1

I'm a complete newbie to this, I've been watching tons of tutorials, reading tutorials, reading the Adobe site, etc... The last time I programmed was BASIC on Apple IIe...

I'm trying to create a preloader that my html page will link to, and when the main .swf file (Portfolio.swf) is loaded, it will display and stop (it's a print swf, so I don't want it to "Play" at 24 frames/sec.)

I have errors in my AS3 of 1120, which I will copy the code here:


stop();
var loader : Loader = new Loader ();

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

loader.load(new URLRequest ("Portfolio.swf"));
function progressHandler(e:ProgressEvent) {
    var percent:Number=Math.round(e.bytesLoaded*100/e.bytesTotal);
    preloader.gotoAndStop(percent);
}
function completeHandler(e:Event) {
    this.addChild(loader);
    this.removeChild(preloader);
}


And here's what I uploaded to my site so far to test:

http://krisbunda.com/templates/portfolio/Portfolio.html

as you can see, it just loops the progress bar, and doesn't load the "Portfolio.swf" file afterward. The actual "Portfolio.swf" can be viewed on this page:

[actually, I'm new, can't post more than 1 hyperlink... you can find the Portfolio on the root of my site.]

it takes a while to download the 6MB+ file, which is why I would like a preloader.

Thanks for your help!

A: 

I finally figured it out, albeit the code has evolved (devolved?) to something different.

I'm not at home to copy the AS3 from my workstation, but here's a link to see the code working as I intended it:

http://krisbunda.com/images/portfolio/Portfolio.html

send me a message if you are having a similar problem and would like the AS3 code pasted here.

Kris