Re: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-27 Thread Fumio Nonaka

I am a little late.  But another way to make the script short:

function dec2hex(input:Number):String {
var hex:Number;
// var stgHex:String = uint(input).toString(16);
var stgHex:String = uint(input+0x100).toString(16).substr(1);
/*
while (stgHex.length  6) {
stgHex = 0+stgHex;
}
*/
stgHex = 0x+stgHex;
return stgHex;
}
_
Robert Leisle wrote:

Hi Jason,

Is something like this what you need?

function dec2hex(input):String {
var hex:Number;
var stgHex:String = uint(input).toString(16);
while (stgHex.length  6){
stgHex = 0+stgHex;
}
stgHex = 0x+stgHex;
return stgHex;
}

function hex2dec(input):String {
return String(uint(input));
}

// test run
var decColor:Number = 102;
var hexColor:String = dec2hex(decColor);
trace(hex: +hexColor);
trace(dec: +hex2dec(hexColor));

--
Fumio Nonaka
http://www.FumioNonaka.com/
My bookshttp://www.FumioNonaka.com/Books/index.html
Flash communityhttp://F-site.org/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Merrill, Jason
How can I translate the ColorPicker.selectedValue to a 6 digit hex
number?  i.e. if the color selected is, 66, if I trace
ColorPicker.selectedColor, traces 102.  I tried gooling for an
Actionscript hex converter, but didn't come up with anything.  Thanks.


Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Merrill, Jason
Sorry, that was meant for the Flex list, but it could also easily be
answered here as well. I'm using the Flex 3 ColorPicker component.
Thanks.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Merrill, Jason
Sent: Thursday, July 24, 2008 1:47 PM
To: Flash Coders List
Subject: [Flashcoders] ColorPicker.selectedValue to #hex?

How can I translate the ColorPicker.selectedValue to a 6 
digit hex number?  i.e. if the color selected is, 66, if 
I trace ColorPicker.selectedColor, traces 102.  I tried 
gooling for an Actionscript hex converter, but didn't come up 
with anything.  Thanks.


Jason Merrill
Bank of America
Enterprise Technology  Global Risk LLD Instructional 
Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative 
learning ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Jim McIntyre

Merrill, Jason wrote:

How can I translate the ColorPicker.selectedValue to a 6 digit hex
number?  i.e. if the color selected is, 66, if I trace
ColorPicker.selectedColor, traces 102.  I tried gooling for an
Actionscript hex converter, but didn't come up with anything.  Thanks.




This may not help, but you can get each RGB color value from the 
selectedValue:


//--
  redValue = selectedValue  16;
  greenValue = (selectedValue  8)  255;
  blueValue = selectedValue  255;
//--

If you're manipulating the number, as opposed to storing or displaying 
it, can't you just work with it in decimal, even if you're using hex 
numbers as operands? This should change the green value to 256:


//--
  newColorValue = selectedValue | 0x00FF00;
//--


If you do need to convert it, what about something like this? (Tested 
only in AS2, but you get the idea.):


//--
function decimalToHex(decVal:Number):String {
  var digits:String = 012345689ABCDEF;
  var returnStr:String = ;
  while (decVal) {
returnStr += digits.substr(decVal  15 -1, 1);
decVal = 4;
  }
  return returnStr;
}

trace(decimalToHex(65535));

// outputs 

//--

-jim

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Merrill, Jason
If you're manipulating the number, as opposed to storing or 
displaying it, 

Thanks, but yeah, the purpose is to display the hex #, the full 6
digits, to the user as #006699.  thanks though!

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Robert Leisle
Hi Jason,

Is something like this what you need?

function dec2hex(input):String {
var hex:Number;
var stgHex:String = uint(input).toString(16);
while (stgHex.length  6){
stgHex = 0+stgHex;
}
stgHex = 0x+stgHex;
return stgHex;
}

function hex2dec(input):String {
return String(uint(input));
}

// test run
var decColor:Number = 102;
var hexColor:String = dec2hex(decColor);
trace(hex: +hexColor);
trace(dec: +hex2dec(hexColor));

hth,
Bob

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
Jason
Sent: Thursday, July 24, 2008 10:47 AM
To: Flash Coders List
Subject: [Flashcoders] ColorPicker.selectedValue to #hex?

How can I translate the ColorPicker.selectedValue to a 6 digit hex
number?  i.e. if the color selected is, 66, if I trace
ColorPicker.selectedColor, traces 102.  I tried gooling for an
Actionscript hex converter, but didn't come up with anything.  Thanks.


Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Hans Wichman
Hi Jason,

trace (Number(102).toString(16));

hth,
JC

On Thu, Jul 24, 2008 at 8:46 PM, Merrill, Jason 
[EMAIL PROTECTED] wrote:

 If you're manipulating the number, as opposed to storing or
 displaying it,

 Thanks, but yeah, the purpose is to display the hex #, the full 6
 digits, to the user as #006699.  thanks though!

 Jason Merrill
 Bank of America
 Enterprise Technology  Global Risk LLD
 Instructional Technology  Media

 Join the Bank of America Flash Platform Developer Community

 Are you a Bank of America associate interested in innovative learning
 ideas and technologies?
 Check out our internal  GTO Innovative Learning Blog  subscribe.


 ___
  Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Jim McIntyre

Merrill, Jason wrote:
If you're manipulating the number, as opposed to storing or 
displaying it, 


Thanks, but yeah, the purpose is to display the hex #, the full 6
digits, to the user as #006699.  thanks though!



The function I included at the bottom should do that. I modified it to 
pad the output with a pound sign and leading zeroes.


//--
function decimalToHex(decVal:Number):String {
  var digits:String = 012345689ABCDEF;
  var returnStr:String = ;
  while (decVal) {
returnStr += digits.substr(decVal  15 -1, 1);
decVal = 4;
  }
  return # + (00 + returnStr).substr(-6,6);
}

trace(decimalToHex(65535));

// outputs #00

//--


-Jim
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] ColorPicker.selectedValue to #hex?

2008-07-24 Thread Merrill, Jason
Here is the function I ended up with if it's useful to anyone, somewhat
deluxe-ified:

public static function decimalToHexidecimal(number:Number,
upperCase:Boolean=false, addPound:Boolean=false, addOx:Boolean=false
):String
{
var hexString:String = Number(number).toString(16);
while (hexString.length  6) hexString = 0 + hexString;
if (addPound) hexString = # + hexString;
if (addOx) hexString = 0x + hexString;
if (upperCase) hexString = hexString.toUpperCase();
return hexString;
}

Thanks again for your help.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders