List Info

Thread: XMLToObjectDeserializer : color type




XMLToObjectDeserializer : color type
country flaguser name
France
2007-04-05 07:26:18
Hi all,

I'm looking at ConfigLoader.
In order to recover a color value as configuration
parameter, i added 
this method in XMLToObjectDeserializer class...
(color can be represented in three way : 0xFFFFFF, #FFFFFF
or simply FFFFFF)
What do you think about it?

Cédric

---------------------------------------------------------
    public function getColor ( node:XMLNode ) : Number
    {
        var string : String =
XMLToObjectDeserializer.stripSpaces( 
node.firstChild.nodeValue );
        var idx_start : Number = 0;
        if(string.substring(0,2) == '0x') {
            idx_start = 2;
        }
        else if (string.charAt(0) == '#') {
            idx_start = 1;
        }
        var hexa : IndexedArray = new 
IndexedArray('0','1','2','3','4','5','6','7','8','9','A','B'
,'C','D','E','F');
        var red : Number =
(hexa.getIndex(string.charAt(idx_start))*16 + 
hexa.getIndex(string.charAt(idx_start+1))) << 16;
        var green : Number = 
(hexa.getIndex(string.charAt(idx_start+2))*16 + 
hexa.getIndex(string.charAt(idx_start+3))) << 8;
        var blue : Number =
hexa.getIndex(string.charAt(idx_start+4))*16 
+ hexa.getIndex(string.charAt(idx_start+5))
        var rgb = red + green + blue;
        return rgb;
    }



_______________________________________________
Pixlib mailing list
Pixlibosflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org


  
Re: XMLToObjectDeserializer : color type
user name
2007-04-10 04:04:17
0xFFFFFF since it the way it represented in ActionScript, no?

On 4/5/07, Lecocq Cédric < c.lecocqpixandlog.com">c.lecocqpixandlog.com > wrote:
Hi all,

I9;m looking at ConfigLoader.
In order to recover a color value as configuration parameter, i added
this method in XMLToObjectDeserializer class...
(color can be represented in three way : 0xFFFFFF, #FFFFFF or simply FFFFFF)
What do you think about it?

Cédric

---------------------------------------------------------
&nbsp; &nbsp; public function getColor ( node:XMLNode ) : Number
&nbsp; &nbsp; {
 &nbsp; &nbsp; &nbsp; &nbsp;var string : String = XMLToObjectDeserializer.stripSpaces(
node.firstChild.nodeValue );
 &nbsp;   ; &nbsp; var idx_start : Number = 0;
 &nbsp;   ; &nbsp; if( string.substring(0,2) == '0x9;) {
 &nbsp; &nbsp;   ; &nbsp; &nbsp; idx_start = 2;
 &nbsp;   ; &nbsp; }
&nbsp;   ; &nbsp; &nbsp;else if (string.charAt(0) == '#';) {
 &nbsp; &nbsp;   ; &nbsp; &nbsp; idx_start = 1;
 &nbsp;   ; &nbsp; }
&nbsp;   ; &nbsp; &nbsp;var hexa : IndexedArray = new
IndexedArray(&#39;0',&#39;1','2','3';,'49;,'5&#39;,'6&#39;,'7','8',';9',9;A',&#39;B',&#39;C','D','E';,'F9;);
   ; &nbsp; &nbsp; var red : Number = ( hexa.getIndex(string.charAt(idx_start))*16 +
hexa.getIndex(string.charAt(idx_start+1))) << 16;
   ; &nbsp; &nbsp; var green : Number =
(hexa.getIndex(string.charAt(idx_start+2))*16 +
hexa.getIndex(string.charAt(idx_start+3))) << 8;
 ; &nbsp; &nbsp; &nbsp; var blue : Number = hexa.getIndex(string.charAt(idx_start+4))*16
+ hexa.getIndex(string.charAt(idx_start+5))
&nbsp;   ; &nbsp; &nbsp;var rgb = red + green + blue;
&nbsp; &nbsp; &nbsp; &nbsp; return rgb;
 ; &nbsp; }



_______________________________________________
Pixlib mailing list
Pixlibosflash.org">Pixlibosflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org



Re: XMLToObjectDeserializer : color type
country flaguser name
Macedonia
2007-04-10 04:27:22

Lecocq Cédric wrote:
> Hi all,
> 
> I'm looking at ConfigLoader.
> In order to recover a color value as configuration
parameter, i added 
> this method in XMLToObjectDeserializer class...
> (color can be represented in three way : 0xFFFFFF,
#FFFFFF or simply 
> FFFFFF)
> What do you think about it?

fine, but you can change all that lookup code you have to
this :

rgb = parseInt(hexa.substring(idx_start),16);




_______________________________________________
Pixlib mailing list
Pixlibosflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )