RGB gradient based on percentage of file loaded
I'm working on my first Flash project, and for my preloader I'd like to do a really simple gradient based on the percentage loaded.  The preloader says "77% loaded...", where the number 77 is a dynamic text instance called percentLoaded.  I'd like the textColor of percentLoaded to change on a gradient from #000000 to #FFFFFF, in gray-scale.

Therefore, I can't simply do:

    percentLoaded.textColor=(currentValue/100)*0xFFFFFF;

This just converts the textColor to a multiple of FFFFFF, but outputs a color since it's not three separate components.  Currently, here's what I've got:

    percentLoaded.text=currentValue.toString();
    percentLoaded.textColor=rgb2hex((currentValue/100)*255, (currentValue/100)*255, (currentValue/100)*255);

Where "rgb2hex" is a function defined within the class as such:

    public function rgb2hex(r:Number, g:Number, b:Number) {
		return '0x'+(r << 16 | g << 8 | b).toString(16).toUpperCase();
	}

It doesn't look like this is actually changing the color of the font though.  I've imported flash.text.TextField and flash.display.MovieClip, but am not sure if I'm missing something else.  Would this be easier to do with string concatenation?  Or is there maybe something going on with currentValue/100 and passing that as a Number?

If curious, I found the code for rgb2hex <a href="http://www.ozzu.com/flash-forum/rgb-code-hex-conversion-code-need-speed-t21429.html">here</a>.

Thanks!
RGB gradient based on percentage of file loaded
===

I'm working on my first Flash project, and for my preloader I'd like to do a really simple gradient based on the percentage loaded.  The preloader says "77% loaded...", where the number 77 is a dynamic text instance called percentLoaded.  I'd like the textColor of percentLoaded to change on a gradient from #000000 to #FFFFFF, in gray-scale.

Therefore, I can't simply do:

    percentLoaded.textColor=(currentValue/100)*0xFFFFFF;

This just converts the textColor to a multiple of FFFFFF, but outputs a color since it's not three separate components.  Currently, here's what I've got:

    percentLoaded.text=currentValue.toString();
    percentLoaded.textColor=rgb2hex((currentValue/100)*255, (currentValue/100)*255, (currentValue/100)*255);

Where "rgb2hex" is a function defined within the class as such:

    public function rgb2hex(r:Number, g:Number, b:Number) {
		return '0x'+(r << 16 | g << 8 | b).toString(16).toUpperCase();
	}

It doesn't look like this is actually changing the color of the font though.  I've imported flash.text.TextField and flash.display.MovieClip, but am not sure if I'm missing something else.  Would this be easier to do with string concatenation?  Or is there maybe something going on with currentValue/100 and passing that as a Number?

If curious, I found the code for rgb2hex <a href="http://www.ozzu.com/flash-forum/rgb-code-hex-conversion-code-need-speed-t21429.html">here</a>.

Thanks!