[Flash9] How to print formatted text

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Flash9] How to print formatted text

ziofu1
I used to use the int.toString(16) to print numbers in Hex format.
How can I do that with HaXe?

Thanks,
Philip

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [Flash9] How to print formatted text

gershon
    //{{{ toHex
    /**
    * @return Flash formatted hex string (0xRRGGBB)
    */
    public static inline function toHex(color:UInt) : String {
        return "0x"+StringTools.hex(color, 6);
    }
    //}}}


On Fri, Nov 13, 2009 at 5:53 PM, ziofu1 <[hidden email]> wrote:
I used to use the int.toString(16) to print numbers in Hex format.
How can I do that with HaXe?

Thanks,
Philip

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [Flash9] How to print formatted text

ziofu1
Thanks..
what about binary conversion?

On Nov 13, 2009, at 5:13 PM, gershon wrote:

    //{{{ toHex
    /**
    * @return Flash formatted hex string (0xRRGGBB)
    */
    public static inline function toHex(color:UInt) : String {
        return "0x"+StringTools.hex(color, 6);
    }
    //}}}


On Fri, Nov 13, 2009 at 5:53 PM, ziofu1 <[hidden email]> wrote:
I used to use the int.toString(16) to print numbers in Hex format.
How can I do that with HaXe?

Thanks,
Philip

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [Flash9] How to print formatted text

gershon
i'd suggest either mine own minimalistic class:
http://haxegui.googlecode.com/svn/trunk/haxegui/utils/Color.hx

or dykam's classes form the excellent more package (also hsl) :
http://gitorious.org/more/more/trees/master/haxe/more/color

On Fri, Nov 13, 2009 at 6:22 PM, ziofu1 <[hidden email]> wrote:
Thanks..
what about binary conversion?

On Nov 13, 2009, at 5:13 PM, gershon wrote:

    //{{{ toHex
    /**
    * @return Flash formatted hex string (0xRRGGBB)
    */
    public static inline function toHex(color:UInt) : String {
        return "0x"+StringTools.hex(color, 6);
    }
    //}}}


On Fri, Nov 13, 2009 at 5:53 PM, ziofu1 <[hidden email]> wrote:
I used to use the int.toString(16) to print numbers in Hex format.
How can I do that with HaXe?

Thanks,
Philip

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [Flash9] How to print formatted text

Nicolas Cannasse
In reply to this post by gershon
gershon a écrit :
>     //{{{ toHex
>     /**
>     * @return Flash formatted hex string (0xRRGGBB)
>     */
>     public static inline function toHex(color:UInt) : String {
>         return "0x"+StringTools.hex(color, 6);
>     }
>     //}}}

You can also do the following :

use StringTools;

45664465.hex();

Nicolas

--
haXe - an open source web programming language
http://haxe.org