0

I have a MainClass and a GUIClass. The MainClass lets the GUIClass handle everything about the GUI. How do I call different Object properties from the MainClass to the GUIClass.

package {

    import gui;
    public class main {
        public var ui:Object = userInterface_mc as Object;
        public var myGui:gui = new gui;

        function main() {
                myGui.prepareObject(ui);
                myGui.tf01 = "foo";
        }
    }

package {
    public class gui {
        private var ui:Object;
        private var textField01:TextField = textField_01 as Textfield;

        function prepareObject (myUI:Object) {
                ui = myUI;
        }
        function set tf01 (myString:String) {
                textField01.text = myString;
        }
    }
}

The code shows how I pass the text property of a TextField. But now I have a ComboBox and I need to fill in data, clear it, receive the label and data. Is there any way to call it like

myData = GUI.comboBox01.data;
myLabel = GUI.comboBox01.label;
GUI.comboBox01.resetAll();
GUI.comboBox01.addItem({label:"foo", data:"baa"});

Best regards

TD

1 Answer 1

1
  1. Stick to naming conventions: Class names should start with an upper case letter, member names should start with a lower case letter.

  2. You can access any property within your gui object, if it is declared public. So if you make comboBox01 a public variable, it will be accessible.

Here's your new code - but not knowing what you're going to do with it, I can only assume where to put what:

package {

    import GUI;
    public class Main {
        public var ui:Object = userInterface_mc as Object;
        public var myGui:GUI = new GUI();
        private var myData : String;
        private var myLabel : String;
        public function main() {
            myGui.prepareObject(ui);
            myGui.tf01 = "foo";
            myData = myGUI.comboBox01.data;
            myLabel = myGUI.comboBox01.label;
            myGUI.comboBox01.resetAll();
            myGUI.comboBox01.addItem({label:"foo", data:"baa"});
        }
    }

package {
    public class GUI {
        private var ui:Object;
        private var textField01:TextField = textField_01 as Textfield;
        public var comboBox01:ComboBox;

        public function prepareObject (myUI:Object) {
                ui = myUI;
        }
        public function set tf01 (myString:String) {
                textField01.text = myString;
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.