3 Replies Latest reply on Jun 10, 2011 7:14 PM by Lancelotian

    how to declare instance of custom actionscript-classes that extend a Flex component

    timo888

      SOLVED.  Was neglecting to add the ".*" after the directory name.

        • 1. Re: how to declare instance of custom actionscript-classes that extend a Flex component
          kkc_mca Level 2

          you can instance in two ways

           

          1) as mxml tag

           

          If you intend to use as an mxml tag you need to specify the name space in the Application tag

           

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxmlxmlns:custom="com.myComponents.*" layout="absolute" />

           

          xmlns:custom="com.myComponents.*"  // the components created in the directory myComponents will be included in the application

           

          <custom:MyText id="txt" /> // custom is the namespace and MyText is the class you declared in myComponents and the instance name is txt

           

           

          2) as actionscript object

          <mx:Script>
               <![CDATA[
                    import com.myComponents.*;
                
                    public var txt:MyText;   // declaring instance of the MyText (custom component)
               ]]>
          </mx:Script>
                  
          If this post answers your question of helps, Please mark it as such .
          • 3. Re: how to declare instance of custom actionscript-classes that extend a Flex component
            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:MyText id="txt" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" />

             

            <fx:Declarations>

            <s:CallResponder id="getAllTreatmentAreaRestylaneResult"/>

            </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

            <mx:Script>
                 <![CDATA[
                      import com.myComponents.*;
                      public var txt:MyText;
            getAllTreatmentAreaRestylaneResult.token = txt.getAll();
                 ]]>
            </mx:Script>
              

            <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>I