flex 颜色值uint与16进制的转换

本文转载自: http://blog.csdn.net/sixingbugai/article/details/6645326 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="init()">
 <mx:Script>
  <![CDATA[

   private var today:Date;
   private var YMD:Date;
   private var datoptions:Array = new Array();
  import mx.controls.Alert;
 public function convertUintToString():void 
            { 
                var xx:uint = new uint(uint_txt.text); 
                result_hexadecimal.text = xx.toString(16); 
            } 
            private function convertStringToUint():void 
            { 
                var colorString:String = "0x" + hexadecimal_txt.text; 
                var colorUint:uint  = mx.core.Singleton.getInstance("mx.styles::IStyleManager2").getColorName( colorString ); 
                result_uint.text = colorUint.toString(); 
            } 
            private function setColor():void 
            { 
                result_final.text = pcolor.selectedColor.toString(); 
            } 
  ]]>
 </mx:Script>
 <mx:HBox width="100%"
    horizontalAlign="center"
    paddingTop="20">
 <mx:Label text="uint和16进制颜色互转" color="#F81E08" fontWeight="bold" fontSize="17"/> 
    <mx:Label text=" 请输入uint值:"/> 
    <mx:TextInput id="uint_txt"/> 
    <mx:Label text="结果为(16进制颜色字符串):"/> 
    <mx:TextInput id="result_hexadecimal"/> 
    <mx:Button label="确定" click="convertUintToString()"/> 
    <mx:Label text=" 请输入16进制颜色字符串:"/> 
    <mx:TextInput id="hexadecimal_txt"/><!--text="#{pcolor.selectedColor.toString(16)}"--> 
    <mx:Label text="结果为(uint):"/> 
    <mx:TextInput id="result_uint"/> 
    <mx:Button label="确定" click="convertStringToUint()"/> 
    <mx:Label text="最直接的16进制颜色转uint:"/> 
    <mx:ColorPicker id="pcolor" change="setColor()"/> 
    <mx:TextInput id="result_final"/> 
 </mx:HBox>
</mx:Application>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值