A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS3 weirdness for Hex converstion.

  1. #1
    Junior Member
    Join Date
    Apr 2018
    Posts
    22

    AS3 weirdness for Hex converstion.

    In AS2:
    var Data:Number = 1763478912341234132;
    trace ( Data.toString(16) ); //3afdd200


    The same code in AS3 says "187922ba3afdd200" !!!
    Where does "187922ba" come from ?

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    What you're probably seeing in AS2 is the decimal number overflowing when it's converted and some bits just getting lost. 1763478912341234132 is 187922BA3AFDD1D4 in hex so the value you got from AS3 is wrong as well. It's only off by 44 though, which is pretty suspicious. The decimal number is only 62 bits so it shouldn't be overflowing.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Here in as3 I took from this operating system library I was working on a script to make fdd200 happen:

    PHP Code:
    var temp_obj={}
    function 
    hexToRGB(hex){
    var 
    red =((hex 0xFF0000) >> 16)
    var 
    green =((hex 0x00FF00) >> 8)
    var 
    blue=((hex 0x0000FF))
    temp_obj={R:red,G:green,B:blue}
    return(
    temp_obj);
    }
    function 
    RGBtoHEX(rgb) {
    var 
    = (<< 16 << b).toString(16);
    while(
    s.length 6s="0"+s;
    return 
    s;
    }

    trace(RGBtoHEX(hexToRGB(1763478912341234132).R,hexToRGB(1763478912341234132).G,hexToRGB(1763478912341234132).B)) 

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center