5 Replies Latest reply on Apr 23, 2010 7:36 AM by FFBB

    Flex 4: Extending custom components

    FFBB

      Hello,

       

      I try to create some custom components on Flex 4, I have:

       

      1. a Shape component (based on Graphic and Path)
      2. a ShapeButton (should extends Shape adding a Label and click EventHandler)

       

       

      My problem is that the ShapeButton component shows the label only, and doesn't shows the elements defined in Shape...

       

       

      Shape:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:local="*"
                 creationComplete="this.currentState = 'up'"
       >
           <s:states>
                <s:State name="up" />
                <s:State name="over" />
                <s:State name="down" />
                <s:State name="selected" />
           </s:states>
           
           <s:Graphic id="graphic"
                width="{this.width}"
                height="{this.height}">
      
                <s:Path data="{_pathData}">
                     <s:fill>
                          <mx:SolidColor id="solidColor" color.up="{_colorUp}" color.over="{_colorOver}" color.down="{_colorDown}" color.selected="{_colorSelected}" />
                     </s:fill>
                </s:Path>
           </s:Graphic>
           
      </s:Group>
      

       

       

      ShapeButton:

       

      <?xml version="1.0" encoding="utf-8"?>
      <basic:Shape xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      xmlns:mx="library://ns.adobe.com/flex/mx" 
                      xmlns:basic="fao.oekc.lms.view.elo.lesson.basic.*"
      >
           
           <s:Label id="label" text="Label" />
           
      </basic:Shape>