2 Replies Latest reply on Jun 11, 2011 4:14 AM by Lancelotian

    How to declare a custome AS-class that extend a Flex componenet

    Lancelotian


      Hello there, would you please help. I have the following mxml tag

       

       

       

      <mx:Application xmlns:mx="xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:custom="com.myComponents.*" layout="absolute" />

       

      <custom:ReturnData id="dataR" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" />

       

       

      <fx:Declarations>

      <s:CallResponder id="getAllResult"/>

      </fx:Declarations>

       

       

      When I change this into AS and try to use the result in a dataGrid, no info will be populated in datagrid, any idea??? It works when use the xmlns tag.

       

       

      2) as actionscript object

      <fx:Script>
           <![CDATA[
                import com.myComponents.*;
                public var dataR:ReturnData;
                getAllResult.token = dataR.getAll();
           ]]>
      </fx:Script>
       

      <mx:DataGrid x="10" y="21" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllResult.lastResult}">

      <mx:columns>

      <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>

      <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>

      </mx:columns>

      </mx:DataGrid>I

        • 1. Re: How to declare a custome AS-class that extend a Flex componenet
          markerline Level 4

          I hesitate to respond because I don't know anything about Flex development yet but I do see a typographical error in your code:

           

          xmlns:mx = "xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:custom="com.myCompontents.*"

          I'm not sure if you're supposed to be declaring the xmlns:fx value without closing the quote or what an fx value is in the first place.  Also you declare on the same line a second xmlns path for your custom com.myComponents.* .  Shouldn't that be a separate <mx:Application xmlns:mx=> tag?

          • 2. Re: How to declare a custome AS-class that extend a Flex componenet
            Lancelotian Level 1

            Thanks for your feedback, my original code is as here below. DataGrid2 populate the data since the component has been initialized in the xmlns. DataGrid does not populate the data and has been initialized by ActionScript???

             

            Any idea where do I do wrong?

            Thanks

             

            <?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" minWidth="955" initialize="application1_initializeHandler(event)" minHeight="600"  xmlns:productrestylaneservice="services.productrestylaneservice.*">

             

            <fx:Script>

            <![CDATA[

            import mx.controls.Alert;

            import mx.events.FlexEvent;

             

            import services.productrestylaneservice.*;

             

             

            [Bindalbe]public var productRestylaneService:ProductRestylaneService;

             

            protected function dataGrid_creationCompleteHandler(event:FlexEvent):void

            {

            getAllTreatmentAreaRestylaneResult.token = productRestylaneService.getAllTreatmentAreaRestylane();

            }

             

            protected function application1_initializeHandler(event:FlexEvent):void

            {

            getAllTreatmentAreaRestylaneResult.token = productRestylaneService.getAllTreatmentAreaRestylane();

            }

             

             

            protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void

            {

            getAllTreatmentAreaRestylaneResult2.token = productRestylaneService2.getAllTreatmentAreaRestylane();

            }

             

             

            ]]>

            </fx:Script>

            <fx:Declarations>

            <s:CallResponder id="getAllTreatmentAreaRestylaneResult"/>

            <s:CallResponder id="getAllTreatmentAreaRestylaneResult2"/>

            <productrestylaneservice:ProductRestylaneService id="productRestylaneService2" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

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

            </fx:Declarations>

            <mx:DataGrid x="10" y="21" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllTreatmentAreaRestylaneResult.lastResult}">

            <mx:columns>

            <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>

            <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>

            </mx:columns>

            </mx:DataGrid>

            <mx:DataGrid x="462" y="21" id="dataGrid2" creationComplete="dataGrid2_creationCompleteHandler(event)" dataProvider="{getAllTreatmentAreaRestylaneResult2.lastResult}">

            <mx:columns>

            <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>

            <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>

            </mx:columns>

            </mx:DataGrid>

             

            </s:Application>