A general OOP question
Hi
I have a general OOP design question, and am wondering if someone could relate an answer to the following design?
I have a class called MediaFolderImport(); - it's designed to build a window with various editing tools in it.
Within it's constructor, I'm calling a bunch of functions to build the window...
createTitle();
createInstructions();
createToolPanel();
createDataGrid ();
createOpen();
createSave();
In my document class, I instantiate it...
public var File_Folder_Import:MediaFolderImport=new MediaFolderImport();
and then...
addChild(File_Folder_Import);
Voila! - the window appears. I WAS very proud of myself.
Now I want to access something inside the window. Specifically, there's a radio button that was created in createToolPanel(); - I want to update it to be selected or not selected when I receieve the user's preference from an xml settings file at start up (xml is loaded into the doc class).
General question:
What is the best practice, smart way to have designed this?
- call createToolPanel(); from the doc class instead of within MediaFolderImport();, and somehow (magically) have access to the radio button?
- leave the design as is, but add some sort of listener within MediaFolderImport that listens for changes to the xml in the doc class, and updates accordingly?
- do it the way I'm trying to, ie try to access the radio button directly from the doc class (which isn't working):
File_Folder_Import.myRadioButton.selected = true;
- a better way someone can briefly explain the concept of?
Another way to explain my design is...
- a bunch of different windows, each created by a different class
- xml file loads preferences, which need to be applied to different tools (radio buttons, check boxes, text fields etc) in the different windows
I read a lot of posts that talk about how public vars are mostly bad practice. So if you are making your class vars private, what is the best way to do the kind of inter-class communicating I'm talking about here?
I think someone throwing light on this will help me solidify my understanding of OOP.
Thank you for your time and help.