Hi Gordon,

I am trying out a few things, below is an example from the Extending
Components.pdf docs, but it doesn't seem to be working.  Can you see
if it works for you?

------------------------------------------

package
{
import mx.core.UIComponent;
import mx.styles.CSSStyleDeclaration;
import mx.styles.StyleManager;
import flash.display.GradientType;
// Insert the [Style] metadata tag to define the name, type
// and other information about the style property for the
// MXML compiler.
[Style(name="fillColors",type="Array",format="Color",inherit="no")]

public class MyTable extends UIComponent
{
      // Define a static variable for initializing the style property.
      private static var classConstructed:Boolean = classConstruct();
      // Define a static method to initialize the style.
     
      private static function classConstruct():Boolean {
            if (!StyleManager.getStyleDeclaration("MyTable"))
      {
      // If there is no CSS definition for StyledRectangle,
      // then create one and set the default value.
      var newStyleDeclaration:CSSStyleDeclaration =
      new CSSStyleDeclaration();
      newStyleDeclaration.setStyle("fillColors", [0xFF0000, 0x0000FF]);
      StyleManager.setStyleDeclaration("MyTable",
      newStyleDeclaration, true);
}

return true;
}
// Constructor
public function MyTable() {
      super();
}
// Define a default size of 100 x 100 pixels.

override protected function measure():void {
      super.measure();
      measuredWidth = measuredMinWidth = 100;
      measuredHeight = measuredMinHeight = 100;
}

// Define the variable to hold the current gradient fill colors.
      private var fillColorsData:Array;
// Define the flag that indicates a change to fillColors.
      private var bFillColorsChanged:Boolean = true;
// Define variables for additional controls on the fill.
// You can create style properties for these as well.
      private var alphas:Array = [1.0, 1.0];
      private var ratios:Array = [0x00, 0xFF];
// Override styleChanged() to detect changes in your new style.
      override public function styleChanged(styleProp:String):void {
      super.styleChanged(styleProp);
// Check to see if style changed.
      if (styleProp=="fillColors"){
            bFillColorsChanged=true;
            invalidateDisplayList();
            return;
      }
}

// Override updateDisplayList() to update the component
// based on the style setting.

      override protected function updateDisplayList(unscaledWidth:Number,
      unscaledHeight:Number):void {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      // Check to see if style changed.
      if (bFillColorsChanged==true)
      {
      // Redraw gradient fill only if style changed.
      fillColorsData=getStyle("fillColors");
      graphics.beginGradientFill(GradientType.LINEAR, fillColorsData,
      alphas, ratios);
      graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
      }
}
}
}

-----------------

Cheers,

Tim






--- In [email protected], "sufibaba" <[EMAIL PROTECTED]> wrote:
>
> Hi Gordon,
>
> Thanks for replying. 
>
> The reason for creating separate sprites is because some of the
> sprites that are created in the box object needs to be added as a
> child to the main custom component that is calling the box object. 
>
> In short, some sprites need to be a direct child of the box object and
> some sprites not. 
>
> I can try to move some of these sprites into updateDisplayList() and
> see what happens. 
>
> However, if the drawing code or display object code section from beta2
> to beta3 hasn't changed then everything should work.
>
> Let me try to post some code for you to see.
>
> Cheers,
>
> Tim
>
>
>
>
> --- In [email protected], "Gordon Smith" <gosmith@> wrote:
> >
> > It sounds like Tim is using addChild(), not <mx:AddChild>.
> >
> > I'm not sure why it broke; I don't think we had to adjust the
> drawing code in our components between Beta 2 and Beta 3. Can you
> simplify the problem and post some code?
> >
> > BTW, why are you creating a separate child Sprite to draw into? Why
> aren't BoxTypeA, etc. overriding updateDisplayList() to do their own
> drawing?
> >
> > - Gordon
> >
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED]
> On Behalf Of Tim Hoff
> > Sent: Wednesday, May 10, 2006 2:22 PM
> > To: [email protected]
> > Subject: [flexcoders] Re: Beta3 Please Help
> >
> > Did you change target to relativeTo in the addChild?
> >
> > --- In [email protected], "sufibaba" <sufibaba@> wrote:
> > >
> > > Hello Everyone,
> > >
> > > I am migrating from Beta2 to Beta3.
> > >
> > > I have a custom component that draws a series of boxes on the
> > screen
> > > from an XML file.  The boxes are attached to one another according
> > to
> > > their parent child relationship that is defined in the XML.
> > >
> > > The boxes have different object types that extend UIComponent:
> > > BoxTypeA, BoxTypeB, BoxTypeC
> > >
> > > within each of the box object is code that creates a sprite (draws
> > the
> > > shape of the box), which is then attached to the parent box object
> > > using the addchild().
> > >
> > > In Beta2, the entire app works perfectly but somehow in Beta3, the
> > > boxes are not drawn within the box Objects. 
> > >
> > > Is this a bug in beta3 do you think?
> > >
> > > Help on this is so much appreciated.
> > >
> > > Cheers,
> > >
> > > Tim
> > >
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to