SWF loading problems

Source: Internet
Author: User
Tags constructor

(Aorition) problem:Recently I made a little thing: two SWF (one primary SWF and one is ready to be loaded into the primary SWF as a module). They are running normally, but once loaded, there is a problem.

Error:
==================================
TypeError: Error #1009: the attribute or method referenced by the null object cannot be accessed.
At AORDATA. AORas: PICmcproClass $ iinit ()
At flash. display: Sprite/flash. display: Sprite: constructChildren ()
At flash. display: Sprite $ iinit ()
At flash. display: MovieClip $ iinit ()
At AORDATA. AORas: PicshowerClass $ iinit ()
TypeError: Error #1009: the attribute or method referenced by the null object cannot be accessed.
At MethodInfo-55 ()
At flash. events: EventDispatcher/flash. events: EventDispatcher: dispatchEventFunction ()
At flash. events: EventDispatcher/dispatchEvent ()
At flash.net: URLLoader/flash.net: URLLoader: onComplete ()
========================================================== ====================
I am confused. How can I solve this problem? In addition, what do you need to pay attention to when doing this loading? Please remind me a lot...

(Poshidon)Reply 1:Test the loaded videos one by one. My experience may be something related to stage...

(Zszen) Reply 2:Prompt that you have an undefined object. Check the code line carefully...

Final Solution:
(Aorition)
Thank you. After careful check, the problem is finally solved. Yes, the problem is that the stage attribute is null, killing the stage of an individual ~~ (Cry)
================================
Detailed analysis and summary:
Because the primary SWF and sub-SWF run independently, once the primary SWF is required to load the sub-SWF, no object or attribute is reported. As a result, the sub-SWF cannot run smoothly.
The reason lies in the stage attribute of the sub-SWF. when running the sub-SWF separately, the instance is already on the stage. therefore, the stage attribute of the sub-SWF exists. therefore, it is normal to reference the stage attribute in the sub-SWF constructor. however, once loaded by the primary SWF. the primary SWF has not reached addChild (sub-SWF), resulting in the stage attribute of the sub-SWF being null. an error occurs when a stage with a null value is referenced in a constructor. so that it cannot be loaded normally.

==========
To solve this problem:
Add (red) to the sub-SWF constructor)
// Example code:
// ========================
Package {
Import flash. display. MovieClip;
Import flash. events. Event;
Public class testClass extends MovieClip {
Public function testClass (): void
            {
            This. addEventListener (Event. ADDED_TO_STAGE, onStageHandler );
            }
Priatve function onStageHandler (evt: Event)
                {
Init ()
This. removeEventListener (Event. ADDED_TO_STAGE, onStageHandler );
                }
Priatve function init (): void
               {
// Put the subject CODE of the sub-SWF here.
// Reference stage attributes
              }
} // Endclass
} // Endpackage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.