1 Reply Latest reply on Apr 1, 2012 11:37 AM by Shongrunden

    This is very simple question. Parent-Child Relationshiop

    havefreetime

      Hi~ All.

      I think this is not too difficult. But I'm newbie to Flex

       

      I don't understand relationship of Parent-Child, and what's different .addElement,  .addChild.

       

      I made some code.

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

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

            xmlns:s="library://ns.adobe.com/flex/spark"

            xmlns:mx="library://ns.adobe.com/flex/mx"

            width="481" height="442" minWidth="955" minHeight="600" creationComplete="initApp()">

      <fx:Script>

        <![CDATA[

         private var _cam:Camera;

         private var _vid:Video;

        

         private function initApp():void{

          _cam = Camera.getCamera();

          _vid = new Video();

          _vid.attachCamera(_cam);

         }

        

         private function createMyVideo():void{

          view.addChild(_vid);

         }

        

        ]]>

      </fx:Script>

      <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <s:Button x="36" y="71" label="Create My Video" click="createMyVideo()"/>

      <s:VGroup x="192" y="71" width="200" height="200" id="view">

      </s:VGroup>

       

      </s:Application>

       

       

      When I click the button, I wanna show my live video.

       

      But I got a error message.

       

      Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.

       

       

      What's my mistake?

       

      Thanks in advance.

       

      Kevin.

       

       

      ps. Sorry for my English.