5 Replies Latest reply on Nov 2, 2009 11:02 PM by arunkumard87

    How to add child in canvas

    arunkumard87 Level 1

      Hai all,

       

      i am trying with the below code to add child in canvas.But its not working.Could anybody help me.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
      <mx:Script>
          <![CDATA[
              import mx.collections.ArrayCollection;
              import mx.controls.Alert;
              import mx.rpc.remoting.RemoteObject;
              import mx.rpc.events.ResultEvent;
             
              [Bindable]
              private var ProductDataService:RemoteObject;
              private var catalog:ArrayCollection;
             
               private function init():void
                  {
                      ProductDataService = new RemoteObject("GenericDestination");
                      ProductDataService.source = "ClassLibrary1.Class1";
                      ProductDataService.addEventListener(ResultEvent.RESULT,ProductResultHandler);
                      ProductDataService.emp();       
                  }
                   private function ProductResultHandler(event:ResultEvent):void
                  {                      
                      catalog = new ArrayCollection(event.result as Array);                               
                      var i:Number=0;               
                      for(i=0;i<catalog.length;i++)
                      {                   
                          var cv:Canvas=new Canvas();
                          cv.label=catalog[i].image;
                          CvEmp.rawChildren.addChild(cv);
                          CvEmp.invalidateDisplayList();
                      }            
                  }          
          ]]>
      </mx:Script>
          <mx:ToggleButtonBar x="0" y="0" id="Tgb" dataProvider="{VwStk}">
          </mx:ToggleButtonBar>
          <mx:ViewStack x="0" y="25" id="VwStk" width="100%" height="506">       
              <mx:Canvas label="homepage" width="100%" height="100%" id="CvHome"
                   showEffect="WipeDown" hideEffect="WipeUp" backgroundColor="#BCB7B7">
                   <mx:Label text="Homepage"/>
              </mx:Canvas>
              <mx:Canvas label="details" width="100%" height="100%" id="CvDtls" creationPolicy="all"
                   showEffect="WipeDown" hideEffect="WipeUp" backgroundColor="#9D9797">
                  <mx:Label x="399" y="0" text="JK Technosoft" id="lblHeading" fontFamily="Georgia" fontSize="15" fontWeight="bold"/>
                  <mx:VBox x="0" y="0" width="20%" height="100%">
                      <mx:Label text="Search" fontWeight="bold"/>
                  </mx:VBox>
                  <mx:HBox x="181" y="21" width="100%" height="100%">
                      <mx:Tile width="729" height="478" id="CvEmp">
                      </mx:Tile>
                  </mx:HBox>
              </mx:Canvas>
          </mx:ViewStack>   
      </mx:Application>

       

      Regards,

      Arun