Flex4 uint color value and hexadecimal color conversion

Source: Internet
Author: User

A few days ago, I encountered the problem that flex needed to use uint to represent the color value,

After exploring the Internet for a long time, I wrote the following code for conversion,

Hope to help you!

 

 

 <? Xml version = "1.0" encoding = "UTF-8"?> <Br/> <mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml" height = "433" width = "397"> <br/> <mx: script> <br/> <! -- [CDATA [<br/> private function convertUintToString (): void <br/> {<br/> var xx: uint = new uint (uint_txt.text ); <br/> result_hexadecimal.text = xx. toString (16); <br/>}< br/> private function convertStringToUint (): void <br/>{< br/> var colorString: string = "0x" + hexadecimal_txt.text; <br/> var colorUint: uint = mx. core. singleton. getInstance ("mx. styles: IStyleManager2 "). getColorName (colorString); <br/> re Sult_uint.text = colorUint. toString (); <br/>}< br/> private function setColor (): void <br/>{< br/> result_final.text = pcolor. selectedColor. toString (); <br/>}< br/>] --> <br/> </mx: Script> <br/> <mx: label text = "uint and hexadecimal color conversion" color = "# F81E08" fontWeight = "bold" fontSize = "17"/> <br/> <mx: label text = "Enter the uint value:"/> <br/> <mx: TextInput id = "uint_txt"/> <br/> <mx: label text = "result: (hexadecimal color string):"/> <br/> <mx: TextInput Id = "result_hexadecimal"/> <br/> <mx: Button label = "OK" click = "convertUintToString ()"/> <br/> <mx: label text = "enter a hexadecimal color string:"/> <br/> <mx: TextInput id = "hexadecimal_txt"/> <! -- Text = "# {pcolor. selectedColor. toString (16)} "--> <br/> <mx: Label text =" result: (uint): "/> <br/> <mx: textInput id = "result_uint"/> <br/> <mx: Button label = "OK" click = "convertStringToUint ()"/> <br/> <mx: label text = "the most direct hexadecimal color to uint:"/> <br/> <mx: ColorPicker id = "pcolor" change = "setColor () "/> <br/> <mx: TextInput id =" result_final "/> <br/> </mx: Application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.