My program works like this:
The main application is made up of two modules – the video module and the text module. The modules are built to be pretty much self-sufficient, with the only point of overlap between them being text highlighting. The text highlighting is a function in the text module which causes the text currently being said covered by the video component to be highlighted (see attached diagram). This means in the main application class the text module must be passed the position of the video. This is done with the following line:
This would all be fine, except for in the main application class, we also set the unit id we wish to use. That unit id is sent to the LoadZipFile.as file, which loads the correct unit, which sends files to the LoadContent.as and LoadResources.as files, which opens the video transcript data and the video file path. The video transcript data is sent to the Text Module and the video file path is sent to the Video Module. The problem is video and text modules in the main application are created before the unit is loaded, so there is a null reference when trying to access the contents of the text area or the video component.
Is there a way to ensure the LoadZipFile class executes and completes its actions before the video and text modules are created?
I didn't read the whole thing. But what you could do , is have the first/primary object fire an event of some type similar to a creation complete event. This event would have a handler , and inside that handler you would instantiate your late-coming objects , since they can't be instantiated before the creation complete event is fired , we know the dependencies are satisfied.