2 Replies Latest reply on Aug 17, 2009 11:56 PM by satyamurthy_hyd

    How to Add/Edit/Delete UI Components(i.e not text values) in a UIContainer as per XML data using mxml.

    satyamurthy_hyd

      Hi All,

      I was asked to make a application for monitoring a remote devices and data is accessed through XMLSocket, the devices at the remote system could be added/deleted at runtime. and Web UI should act accotdingly. What is the best way of approch to implement it ?is it using mxml component or using action script?.I already implemented using mxml and could display devices in Web, for dynamic addiotion/deletion/edition of devices and its properties i'm looking for your inputs/suggestion.

      thanks in Advance.

        • 1. Re: How to Add/Edit/Delete UI Components(i.e not text values) in a UIContainer as per XML data using mxml.
          kkc_mca Level 2

          hi satyamurthy,

           

          assign unique name to each of the UIComponents adding to the container ( default stage )

           

          by using the name property of the components you can get the object from the container using

           

          container.getChildByName("name assigned to the property") this function will return as DisplayObject

           

          typecast the DisplayObject to the target class to that you can edit the object.

           

          example:

          var sp:Sprite = myContainer.getChildByName("one") as Sprite;   // here I am getting sprite reference with name 'one' from 'myContainer'

          sp.x=sp.x + 10;  // here I am editing the property 'x' of the Sprite whose name is 'one'

          Note : similarly you can perform operation on the sprite

           

          Deleting UIComponent:

           

          removeChild will be used to remove the child from the container where it is added

           

          container.removeChild(container.getChildByName("name assigned to the property"));

           

           

          If this post answers your question or helps, please mark it as such

          • 2. Re: How to Add/Edit/Delete UI Components(i.e not text values) in a UIContainer as per XML data using mxml.
            satyamurthy_hyd Level 1

            Dear KKC,

            Thanks for the mail.

            I have done the same.

            But now the problem is the components to be added or deleted are having the child components on it.when i try to set their properties at Runtime,it is throwing "Can't access property or method of a null object reference".

            Find the attachment to understand the problem description

            I understand these child component of the component to be added/deleted are not created and calling at runtime ,so i appreciate any of your further suggestions or input are more helpful for me:

            Thanks in advance