1 Reply Latest reply on Sep 2, 2007 11:57 AM by Ansury

    Interacting with UI components

    Ansury Level 3
      I'm trying to find a GOOD way of interacting with UI components from outside classes. For example, say you have a "controller" class that needs to access the UI view in some way (set a label's text or whatever). The controller class doesn't extend anything, it just deals with the logic of what should be happening. Right now it's being created by my top level class when the program starts up. It listens for certain events to occur, and needs to update/interact with the UI or application state depending on what the events are. I don't seem to have a way for this controller class to easily access the UI component that I need to get a hold of.

      I'm trying to do this to shrink the size of a rapidly growing WindowedApplication mxml file (AIR class but that isn't important), and to take some of the application logic out of that file.

      This is complicated by the fact that the label is in a state that isn't the "base" state (so it's not a child, or even a sub-child of the main class at startup time), and by the fact that it's not even close to a secondary-level component. (If it was, I could probably just pass the label object into the constructor for the outside class.)

      In other words, I can't just call getChild("labelName") on my "main" application object because it's nested/buried inside OTHER components. I don't think I like the idea of recursively cycling through all components and subcomponents, looking for the component that my outer class is trying to request. I've thought of some other ideas but I don't like any of them enough to bother trying them, heh.

      I'm at the point now where I've just about come to the conclusion that either my fundamental design strategy is flawed, or Flex just doesn't allow for complex applications where GUI components can interact with outer classes relatively painlessly. I'm not convinced that "Flex can't do it", so I'm looking for advice on some overall large Flex application design patterns.

      Where do you put this kind of control logic, and what happens when it starts to overflow and become so big that you need to break it off into other files?