3 Replies Latest reply on Oct 11, 2008 8:13 AM by sjerry-

    Extending component with code behind

    sjerry-
      Hi,

      I have read an article about extending components with code behind: http://www.adobe.com/devnet/flex/quickstart/building_components_using_code_behind/

      I have a question about that. Maybe someone can help me.

      Example:
      {components/CartClass.as}
      package components
      {
      public class CartClass extends DataGrid
      {
      public function CartClass()
      {
      super();

      }
      }
      }


      {components/Cart.mxml}
      <?xml version="1.0" encoding="utf-8"?>
      <shop:CartClass xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns:shop="components.*"
      >

      </shop:CartClass>

      Everthing works fine but when i add:
      <mx:columns>
      <mx:DataGridColumn headerText="Title" />
      </mx:columns>

      between the shop:CartClass tag, Flex says:
      Could not resolve <mx:columns> to a component implementation

      Anyone knows why?

        • 1. Re: Extending component with code behind
          ruffing232
          You'll need to use shop instead of mx when doing mx:columns. Because you've done shop:CartClass, you are using shop as a namespace and so using mx:columns does not refer to the shop:CartClass columns properties, but rather the mx:CartClass that doesn't exist.

          • 2. Re: Extending component with code behind
            Level 7

            "sjerry-" <webforumsuser@macromedia.com> wrote in message
            news:gcq38m$1rg$1@forums.macromedia.com...
            > Hi,
            >
            > I have read an article about extending components with code behind:
            > http://www.adobe.com/devnet/flex/quickstart/building_components_using_code_behin
            > d/
            >
            > I have a question about that. Maybe someone can help me.
            >
            > Example:
            > {components/CartClass.as}
            > package components
            > {
            > public class CartClass extends DataGrid
            > {
            > public function CartClass()
            > {
            > super();
            >
            > }
            > }
            > }
            >
            >
            > {components/Cart.mxml}
            > <?xml version="1.0" encoding="utf-8"?>
            > <shop:CartClass xmlns:mx=" http://www.adobe.com/2006/mxml"
            > xmlns:shop="components.*"
            > >
            >
            > </shop:CartClass>
            >
            > Everthing works fine but when i add:
            > <mx:columns>
            > <mx:DataGridColumn headerText="Title" />
            > </mx:columns>
            >
            > between the shop:CartClass tag, Flex says:
            > Could not resolve <mx:columns> to a component implementation

            columns is actually a property of the DataGrid instance, rather than the
            DataGrid class itself, so it needs to be in the same namespace as the actual
            DataGrid subclass:

            <shop:columns>
            <mx:DataGridColumn headerText="Title" />
            </shop:columns>




            • 3. Re: Extending component with code behind
              sjerry- Level 1
              I see. Thanks man. I'm just started with Flex so i have to learn a lot... :-)