English 中文(简体)
Flash AS3 Preloader error: 1120 access of undefined property, preloader?
原标题:

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!

问题回答

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.





相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签