(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