13 Replies Latest reply on Jan 30, 2009 8:37 AM by Newsgroup_User

    Adding child components

    amthekkel Level 1
      Hi all,

      i have a file that contains the layout of my application. I am wanting to divide my application into two halves, on the left half i want to display the menu and link buttons etc, on the right half i would like to display the corresponding functionality.
      So i had a main HBOX and split it into two VBOX (left, right) containers. I have few mxml file which contains functionality like login, liststaff etc. each of these have their own container such as a VBOX or HBOX etc.
      On the click of the link button for e.g. login i want the right VBox to add the login.mxml file, and if the liststaff button is clicked then i want the Right VBOX to remove the login.mxml component first and then add liststaff.mxml component.

      I tried the following
      mx.core.Application.application.mainBox.mainPanel.addChild(com.hrnet.components.login);

      where com.hrnet.components.login refers to my login.mxml file and mainPanel refers to right VBOX.

      When i do the above, i get a type coerrsion error as it requires a DisplayObject.. I am not sure how to solve this issue, Can anyone suggest me a way to add and remove the components to my VBOX .

      thanks

      abhi