AS3 Preloader Errors

Hi There

I have implemented Lee Brimlows AS3 preloader (http://www.gotoandlearn.com/play?id=85) successfully in its basic form but as soon as I try to expand on the functionality of the preloader I get output errors.

I have added a graphic/ MC to the stage call preLogo which contains a few graphical elements and a counter that I animate, the animation + preloading works fine but it seems to be the issue with the adding bits to the stage, where is goes wrong. I keep getting the following output error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AntMain/initStage()
at AntMain/initSite()
at AntMain/pressImageLoadComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at br.com.stimuli.loading::BulkLoader/_onAllLoaded()
at br.com.stimuli.loading::BulkLoader/_onItemComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at br.com.stimuli.loading.loadingtypes::LoadingItem/onCompleteHandler()
at br.com.stimuli.loading.loadingtypes::ImageItem/onCompleteHandler()

This error is within a function in the swf I am preloading, my main MC.

Please find attached my code, I have tried it with Tweener and TweenLite and get similar errors, I have attached the TweenLite Version of the AS3 I have written. As soon as I take the tweening code out of the preInitSite() function it works, but obviously the required animations do not.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Its really strange, the movie that is loading in has no issues and run fine if accessed directly and also if I use the basic preloader that I mentioned earlier.

I really feel the issue is with the preLoadComplete function, if i replace the code in this function with a call to preInitSite(); the whole thing works fine! It must be something to do with clearing the stage and adding the new swf.

I have attached the fla for the loader, yes preLoader is on the stage.

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

point 3. that's what i'm saying. that's the file you first uploaded. when i run it I AM NOT getting any errors, and i'm able to successfully load a file, hence I'm thinking there's something wrong somewhere else. Looking at AntLoadOld is not going to help right because you're not using that file
in order to determine where the problem is, need your swf file.
if i then get the error then we know the error is in your main.swf and not preloader swf.

ok what does AntMain.swf on its own do?
is there actually something visual there?
I can still load it without the null error you're getting. I'm getting IOErrors for missing xml files which i'm assuming is right.

I did infact fix this last night, it was the issue described referenced IqAndreas. The loaded swf trying to access the stage. I fixed it by adding the ADDED_TO_STAGE event listener to the main document class, see attached code.

@ig
"
Also, is there a difference between closing a question and setting the answer to the last one you posted? I'm still a little shaky on how it all works..."

if there are no comments, the asker can simply delete the question, however if there are, there are a few options.
1. if you got a solution from a volunteer then you can assign them the points and close it that way.
2. if you found the solution yourself you can post your solution and accept that as the answer, that way closing the question and the asker getting his points back.
3. if the asker found his own solution but did get some assistance they can choose to split the points.
4. if the asker point blank neglects the question, the clean up crew will force accept, close with no refund , or close and refund.