16 Replies Latest reply on Apr 26, 2009 3:00 PM by Michael Borbor

    Problem with child tag - Could not resolve x to a component implementation.

      Hello.

      I am writing some chart component and got a problem setting property via child tag. Property is a custom class.

      My directory structure:

      .:
      Makefile  oxcharts  Session.vim  stats.as  stats.mxml  stats.swf

       

      ./oxcharts:
      ColumnChart.as MyTest.as

       

      stats.mxml:

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:oxcharts="oxcharts.*">

      .....

       

          <oxcharts:ColumnChart id="myChart" showDataTips="true" width="600" height="310">

              <oxcharts:test x="5"></oxcharts:test>
           </oxcharts:ColumnChart>

      ....

      </mx:Application>

       

      ColumnChart.as:

      package oxcharts {

       

      .........
          public class ColumnChart extends UIComponent {
              ..........
              public var test:MyTest;

              ........

         }

      }

       

      MyTest.as:

      package oxcharts {
          public class MyTest {
              public var x:Number;
          }
      }

       

      I got this error:

       

      Error: Could not resolve <oxcharts:test> to a component implementation.

       

      I guess something wrong with imports. Setting Number property via child tag works just fine.

        • 1. Re: Problem with child tag - Could not resolve x to a component implementation.
          Michael Borbor Level 4

          You get that erro because it's not a component, your custom comps are  ColumnChart and MyTest

          • 2. Re: Problem with child tag - Could not resolve x to a component implementation.
            Level 1

            I'm new to actionscript. Could you give a more verbose answer? test attribute of class ColumnChart has type MyTest. Why i can't set it's properties via child tag?

            • 3. Re: Problem with child tag - Could not resolve x to a component implementation.
              Michael Borbor Level 4

              Ok, look in ActionScript when you create a component using an .as file, that's the name of your component for instance y create a component named MyAmazingCanvas.as, that's gonna be my custom comp. name, and supposed I have a public var within MyAmazingCanvas named myPublicNumber. If I add MyAmazingCanvas. as to a Flex app and I set the xmlns to oxcharts just like you did. I'll instantiate my component within my app, and set the value to myPublicNumber like this:

               

              <oxcharts:MyAmazingCanvas id="myCustomComp" myPublicNumber="323" />
              

              So when you set a variable within a custom component you have access to that variable in a property-like style.

              • 4. Re: Problem with child tag - Could not resolve x to a component implementation.
                Level 1

                Hmm. It's ok when a variable has some simple type like Number. And if myPublicNumber has to be some custom class? Which has it's own property myPublicNumber2. And i want to set that property? How can i do that?

                In my case - this class is MyTest. It's located in same package oxcharts and has property x of type Number. I want to set it somehow.

                • 5. Re: Problem with child tag - Could not resolve x to a component implementation.
                  Michael Borbor Level 4

                  It's almost the same, there the only thing is that you requiere an extra step,you need to create a var at the top level that which type is MyClass and then set the values that you want to pass to your component through this var.

                  • 6. Re: Problem with child tag - Could not resolve x to a component implementation.
                    Level 1

                    At top level - you mean in package, not in class?

                    Flex complains:

                    Error: A file found in a source-path can not have more than one externally visible definition. oxcharts:test;ox
                    charts:ColumnChart

                     

                    package oxcharts {

                    .......
                        public var test:MyTest;

                     

                        public class ColumnChart extends UIComponent {
                           .....

                        }

                    }

                    • 7. Re: Problem with child tag - Could not resolve x to a component implementation.
                      Michael Borbor Level 4

                      I'm gonna give a clerear example, I hope it'll help you better understand what I mean let's say I have a custom class named Login:

                       

                      package ec
                      {
                               [Bindable]
                           public class Login
                           {
                                
                                public var ID:int;
                                public var Role:String;          
                                public function Login()
                                {
                                     
                                }
                      
                           }
                      }
                      

                      And I need to use this class within MyAmazingCanvas, so my main app will be like this:

                       

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:oxcharts="ec.*">
                           <mx:Script>
                                <![CDATA[
                                     import ec.Login;
                                     
                                     [Bindable]
                                     private var myLoginStatus:Login=new Login();
                                     
                                     private function setLoginData():void{
                                          myLoginStatus.ID=myID.text
                                          myLoginStatus.Role=myRole.text;
                                     }
                                ]]>
                           </mx:Script>
                           
                           <oxcharts:MyAmazingCanvas id="myCustomComp" myPublicNumber="323" LoginStatus="{myLoginStatus}" />
                      
                           <mx:TextInput id="myID" />
                           <mx:TextInput id="myRole" />
                           <mx:Button id="setData" label="Set Data" click="setLoginData()" />
                      </mx:Application>
                      

                      When I said at the top level I meant outside the scope of any function, altough is not a requierement, you can as well set it at a function level.

                      • 8. Re: Problem with child tag - Could not resolve x to a component implementation.
                        Level 1

                        I got your idea. But it looks like a hack

                        Look at original flex charts xml example:

                        <?xml version="1.0"?>
                        <!-- charts/BasicColumn.mxml -->
                        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                          <mx:Script><![CDATA[
                             import mx.collections.ArrayCollection;
                             [Bindable]
                             public var expenses:ArrayCollection = new ArrayCollection([
                                {Month:"Jan", Profit:2000, Expenses:1500},
                                {Month:"Feb", Profit:1000, Expenses:200},
                                {Month:"Mar", Profit:1500, Expenses:500}
                             ]);
                          ]]></mx:Script>
                          <mx:Panel title="Column Chart">
                             <mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
                                <mx:horizontalAxis>
                                   <mx:CategoryAxis 
                                        dataProvider="{expenses}" 
                                        categoryField="Month"
                                   />
                                </mx:horizontalAxis>
                                <mx:series>
                                   <mx:ColumnSeries 
                                        xField="Month" 
                                        yField="Profit" 
                                        displayName="Profit"
                                   />
                                   <mx:ColumnSeries 
                                        xField="Month" 
                                        yField="Expenses" 
                                        displayName="Expenses"
                                   />
                                </mx:series>
                             </mx:ColumnChart>
                             <mx:Legend dataProvider="{myChart}"/>
                          </mx:Panel>
                        </mx:Application>

                        I don't need to instantiate horizontalAxis class of flex chart in my application and set it like a xml property. I just write child tag for it. I want users of my chart to be able to write similar xml code without any actionscript. Is it possible?

                        • 9. Re: Problem with child tag - Could not resolve x to a component implementation.
                          Michael Borbor Level 4

                          You're funny it's not a hack it just a way of programming You could've done this as well

                           

                          <uae:Login>
                               <uae:ID>{myID.text}</uae:ID>
                               <uae:Role>{myRole.text}</uae:Role>
                          </uae:Login>
                          
                          1 person found this helpful
                          • 10. Re: Problem with child tag - Could not resolve x to a component implementation.
                            Level 1

                            Ok. Another question. How can mx:ColumnChart understand what programmer wants it to do here?

                            <mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
                                    <mx:horizontalAxis>
                                       <mx:CategoryAxis
                                            dataProvider="{expenses}"
                                            categoryField="Month"
                                       />

                                    </mx:horizontalAxis>
                                    <mx:series>
                                       <mx:ColumnSeries
                                            xField="Month"
                                            yField="Profit"
                                            displayName="Profit"
                                       />

                                       <mx:ColumnSeries
                                            xField="Month"
                                            yField="Expenses"
                                            displayName="Expenses"
                                       />

                                    </mx:series>
                                 </mx:ColumnChart>

                            What is a type of horizontalAxis and series attributes of mx:ColumnChart component? Some classes?

                            • 11. Re: Problem with child tag - Could not resolve x to a component implementation.
                              Michael Borbor Level 4

                              I don't understand your question could you explain me what you mean?

                              • 12. Re: Problem with child tag - Could not resolve x to a component implementation.
                                Michael Borbor Level 4

                                I got it know, some are properties, some are another classes. The column

                                chart expect data in any format and then iterate through it to represent the

                                data graphically.

                                • 13. Re: Problem with child tag - Could not resolve x to a component implementation.
                                  Level 1
                                  <mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
                                          <mx:horizontalAxis>
                                             <mx:CategoryAxis
                                                  dataProvider="{expenses}"
                                                  categoryField="Month"
                                             />

                                          </mx:horizontalAxis>
                                  </mx:ColumnChart>

                                  mx:ColumnChart has an attribute horizontalAxis. What type is it? Some custom class? Or just some XML object?

                                  For example:

                                  <mycomp:SomeComp>
                                       <mycomp:SomeComplexAttribute a="5" b="6"/>
                                  </mycomp:SomeComp>
                                  

                                   

                                  package mycomp {
                                       public class SomeComp {
                                            public var SomeComplexAttribute:UnknownType;
                                       }
                                  }
                                  

                                  What should i use instead of UnknownType to haldle such child tag? Some class with attributes a and b? Or just XML object?

                                  • 14. Re: Problem with child tag - Could not resolve x to a component implementation.
                                    Michael Borbor Level 4

                                    horizontalAxis is a property within a parent class of ColumnChart, if you

                                    read the documentation you'll see that horizontalAxis expects some value

                                    that implements the interface IAxis, and CategoryAxis implements that. So as

                                    a general rule when you see the first letter in lowercase, and then camel

                                    case is a property, and so if it begins with uppercase is a class, so you

                                    can figure stuff from there.

                                    1 person found this helpful
                                    • 15. Re: Problem with child tag - Could not resolve x to a component implementation.
                                      Level 1

                                      I think i got it. I should write

                                      <oxcharts:test>
                                           <oxcharts:MyTest x="5"/>
                                      </oxcharts:test>

                                      instead of

                                      <oxcharts:test x="5"/>

                                      Thanks alot I was trying to solve this problem for three days...

                                      • 16. Re: Problem with child tag - Could not resolve x to a component implementation.
                                        Michael Borbor Level 4

                                        Glad I was able to help you. Keep on developing my friend!