6 Replies Latest reply on Jan 25, 2012 11:41 PM by havefreetime

    [BASIC] The supplied DisplayObject must be a child of the caller??

    havefreetime Level 1

      Hi~ All.

      Please read my sample code. I cannot understand Parent-Child relationship. I konw, this is very easy. But I'm new to FLEX. Please help me!!

       

      I

       

      Test.mxml

      <fx:Script>

        <![CDATA[

         import mx.managers.PopUpManager;

         private function add():void{

          var test2:Test2 = new Test2();                         ----> What is test2's parent??

          addElement(test2);

         }

        ]]>

      </fx:Script>

        <s:Button x="304" y="181" label="Button" click="add()"/>

      </s:Application>

       

      ------------------------------------------------------------------------------------------ --------------------------------------

       

      Test2.mxml

      <fx:Script>

        <![CDATA[

         import mx.controls.Alert;

        ]]>

      </fx:Script>

      <s:Button x="241" y="106" label="Button" click="mx.controls.Alert.show('테스트');"/>

      </s:Application>

       

       

       

      I run the Test.mxml, and when I click the Test.mxml 's button, I can call Test2's button.

       

      When I click Test2's button, the error occurs like this....

       

      2025 : The supplied DisplayObject must be a child of the caller.

       

      I can't understand this message. Please help me.

       

      Thanks in advance

       

      Kevin.