0 Replies Latest reply on Jun 1, 2011 5:31 AM by TheGarfunkal

    Putting my FillFunction in a Package for Reuse

    TheGarfunkal

      Hi

       

      I fully expect this is an easy one but I can't seem to crack it

       

      I have a fill function for a PieChart that I seem to use all over the place, so a want to shove it into a package for reuse.  Sadly I've hit bit of a wall with Syntax.

       

      Initially I put it straing into the class, but constructors can't return so I have messed about and now I dunno whats going on...

       

      my current error is 'In initializer for 'fillFunction': type com.rsagroup.flex.cmiportal.renderers.Rags is not assignable to target type Function. '

      Any ideas or suggestions?  I cant seem to get at the function RagsFill.

       

      Pie Code:

       

                <mx:PieSeries>

                     <mx:field>Volume</mx:field>

                     <mx:nameField>RAG</mx:nameField>

                     <mx:explodeRadius>0.05</mx:explodeRadius>

                          <mx:fillFunction>

                               <renderers:Rags/>

                          </mx:fillFunction>

                     <mx:itemRenderer>

                          <mx:Component>

                               <renderers:RollOverWedgeItemRenderer />                         

                          </mx:Component>

                     </mx:itemRenderer>

                     <mx:showDataEffect>

                          <mx:SeriesInterpolate duration="1000"/>

                     </mx:showDataEffect>

                </mx:PieSeries>

       

      what would be my package

       

      package com.rsagroup.flex.cmiportal.renderers

      {

           import mx.charts.series.items.PieSeriesItem;

           import mx.graphics.IFill;

           import mx.graphics.SolidColor;

           import com.rsagroup.flex.cmiportal.renderers.Rags;

           

           public class Rags

           {

                public function Rags():void

                {

       

                }

                public static function RagsFill(element:PieSeriesItem, index:Number):IFill

                {

                     var c:SolidColor = new SolidColor(0xf7ba48); 

                     var item:PieSeriesItem = PieSeriesItem(element);

                    

                    //Chart is RAG  - then derive colour from item.item.RAG

                   

                   if (item.item.RAG == "Red")

                     c.color = 0xFF0000;   

                  else if (item.item.RAG == "Amber")

                     c.color = 0xf7ba48; 

                  else if (item.item.RAG == "Green")

                      c.color = 0x1bea15 ;                           

                return c;

       

                  }

      }

      }