Loaded SWF not executing as expected? (AS3)


A best practices way of loading a SWF withing another SWF is

        public function Constructor() {
            if (stage == null)        {
                addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
            }else{
                onAddedToStage();
            }
        }

        private function onAddedToStage(event:Event = null):void{
            init();
        }
private function init(){
//typical constructor code
}

The problem with putting some types of code in the constructor is that the SWF may not yet be added to the Display tree, and stage-aware code will return nulls and errors. So, if an application works on the desktop but not on the test server when loading nested SWFs, have a look at this possibility.

A good description is here:

http://www.markledford.com/blog/2008/08/13/why-some-as3-swfs-work-stand-alone-but-fail-to-load-into-other-swfs/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s