YOUR FEEDBACK
AJAX World - Sun Talks Up its Late-to-the-Party AIR-Silverlight Rival
JavaFX News Desk wrote: At Java One this week Sun has been selling its year ...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
MXDJ TOP LINKS YOU MUST CLICK ON !


Converting Back and Forth Between Hexidecimal Strings and Numbers
It's really convenient for anyone coming from an HTML background that we can now provide colors to Flex

Digg This!

Jeff Tapper's Blog

It's really convenient for anyone coming from an HTML background that we can now provide colors to Flex using html standard syntax for hexidecimal number (#000000 = black, #ffffff= white, etc).  I've recently been building some tools to convert drawings in the flash player to and from SVG format. SVG, like HTML, likes to specify hexidecimal numbers with a "#" prefix, but the flash player drawing API needs hexidecimal numbers to be prefixed with "0x"  To help migrate back and forth between hexStrings and AS numbers, I wrote a few static methods, which are working well for me:

package utils {
 public class Colors {
  public static function hexStringToNumber(hexStr:String):Number{
   if(hexStr.length != 7){
    return -1;
   }
   if(hexStr.charAt(0) != "#"){
    return -1;
   }
   var newStr:String = hexStr.substr(1,6);
   var numStr:String = "0x"+newStr;
   var num:Number = Number(numStr);
   return num;
  }
  public static function numToHexString(num:Number):String{
   var hexStr:String = num.toString(16);
   while(hexStr.length < 6){
    hexStr = "0"+hexStr;
   }
   hexStr = "#"+hexStr;
   return hexStr;
  }
 }
}

As you can see, there are 2 methods hexStringToNumber and numToHexString.  These can be used simply like this:

var whiteNum:Number = Colors.hexStringToNumber ("#ffffff");
var whiteStr:String = Colors.numToHexString(16777215);
About Jeff Tapper
Jeff Tapper, co-founder of Tapper, Nimer and Associates, is an Editorial Board member of Web Developer's & Designer's Journal. He has been developing Internet-based applications since 1995, for a myriad of clients including Toys R Us, IBM, Allaire, Dow Jones, American Express, M&T Bank, Verizon, Allied Office Supplies, and many others. As an Instructor, he is certified to teach all of Adobe's courses on Flex, ColdFusion and Flash development. He has worked as author and technical editor for several books on technologies including Flex, Flash and ColdFusion, such as "Object Oriented Programming with ActionScript 2.0", and "Flex 2 Training from the Source."

Web Developer's & Designer's Journal wrote: It's really convenient for anyone coming from an HTML background that we can now provide colors to Flex using html standard syntax for hexidecimal number (#000000 = black, #ffffff= white, etc). I've recently been building some tools to convert drawings in the flash player to and from SVG format. SVG, like HTML, likes to specify hexidecimal numbers with a '#' prefix, but the flash player drawing API needs hexidecimal numbers to be prefixed with '0x' To help migrate back and forth between hexStrings and AS numbers, I wrote a few static methods, which are working well for me:
read & respond »
LATEST FLEX STORIES & POSTS
AJAX World - Xceed Launches Microsoft Silverlight 2 Control
Xceed launched Xceed Upload for Silverlight, the commercial offering in support of Microsoft's promising new Silverlight technology. The product is available now for purchase or as a fully functional 45-day trial on Xceed's website. Xceed Upload for Silverlight lets developers add uplo
AJAX World - Sun Talks Up its Late-to-the-Party AIR-Silverlight Rival
At Java One this week Sun has been selling its year -old-but-still-upcoming - and definitely late-to-the-party - Adobe AIR- and Microsoft Silverlight-competitive JavaFX Rich Client environment as a potential revenue-generator capable of putting ads on mobile applications and JavaFX Scri
AJAX World - Skyway Software Announces RIA Developer Contest
According to Sean Walsh, President and CEO of Skyway Software, 'Our Skyway Community is thriving and our members are very talented. We truly look forward to their RIAs submittals and Skyway Builder extensions and are excited that all of the contributions will benefit the entire Skyway
"Virtualization Journal" Debuts This Week at JavaOne
Founded in 2006, SYS-CON Media's 'Virtualization Journal' is the world's first magazine devoted exclusively to what Gartner has earmarked as the single highest-impact IT trend through 2012: virtualization. And now it will be available on newsstands worldwide, as SYS-CON Media seeks to
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
Microsoft To Keynote 4th International Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE