Need some basic AS3 advice please

I’m still getting my head wrapped around the whole encapsulation thing and thinking from “outside to in” as described by senocular here: http://www.kirupa.com/forum/showthread.php?p=2167721#post2167721

Basically, I make quasi-desktop apps with flash for kiosks. I have a “home screen” with buttons and the buttons load other “screens” with further information.

In AS2 I used to do this by either loading a home screen swf and then loading other swfs screens on top of that, attaching them to loader movie clips or making the screens on different frames of the main timeline and moving the play head to navigate the user to each new view.

Now, I’m trying to change my approach in AS3 by loading new SWFs for each screen and having a document class for each SWF screen that takes care of all the buttons, data handling/display and loading/unloading each screen.

I’m running into a lot of problems with this, mainly stemming from SWFs not being able to unload themselves. For instance, I’ll have a “BaseApp” class/SWF that loads a “HomeScreen” class/SWF in it’s contructor. I’ll define eventListeners for some buttons on the home screen (writing the code for this in the HomeScreen class) that I want to unload the home screen and load another subpage. The first problem I run into is not being able to unload HomeScreen from a button within HomeScreen. I’ll try something like parent.removeChild(this) to which Flash throws me errors like caller can not be child of callee, or something like that.

No doubt this looks like a familiar problem to some of you and I am suspecting my approach to this is fundamentally flawed.

SO, I am reaching out for someone to point me in a new direction for the simple functionality described above. Should I instead be using the Library and not external SWFs? Should I be instantiating classes that load the external SWFs themselves (as opposed to using the Loader object and document classes for each external SWF)… Should I forget about trying associate each “screen” with it’s own class, instead relying on one document class that handles all of the coding for each sub-screen?

I feel like I just need some high level philosophical guidance here :wink: