How to dynamically fill a progress bar in Flex/Actionscript? -


i want create progress bar of % of filled in different color based on variable. example 33 % fill 33 % of progress bar different color , 40 % likewise, fill 40 % of it. best way in actionscript , flex 3?

the way i've done in past create custom progress bar skin, set fill gradient goes entire length of bar (even though smaller portion of bar gets drawn.) sounds strange use gradient has hard stops colors, it's pretty easy. set stop next color right next end stop previous color. here's example color changes green red @ mid point:

package some.package.skins {     import flash.display.gradienttype;     import flash.geom.matrix;      import mx.core.uicomponent;     import mx.skins.halo.progressbarskin;      public class coloredprogressbarskin extends progressbarskin     {         override protected function updatedisplaylist(w:number, h:number):void {             super.updatedisplaylist(w, h);             graphics.clear();              var fullwidth:int = w;             if (parent != null && (parent uicomponent).mask != null)                 fullwidth = (parent uicomponent).mask.width;              var matrix:matrix = new matrix();             matrix.creategradientbox(fullwidth, h);             var colors:array = [0x00ff00, 0x00ff00, 0xff0000, 0xff0000];              this.graphics.linestyle();             this.graphics.begingradientfill(gradienttype.linear, colors, [1,1,1,1], [0,128,128,255], matrix);             this.graphics.drawroundrect(2, 2, w - 4, h - 4, h - 4);          }      } } 

you set skin barskin style on progress bar, either in css or in tag use progress bar.

hope helps.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -