Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-2008, 06:16 AM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default convert int to hex

Hi, my maths skills arent up to this. I need to convert an interger to a hexidecimal value.

like -1 to a value like 0xFFFE (not that that is correct)

Hope you can help
jon
Reply With Quote
  #2 (permalink)  
Old 03-12-2008, 11:45 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: convert int to hex

In ffish script you can use
Code:
var i = -1324;
var ihex = i.format("0X%08X");
trace(ihex);
However, it is not a standard method of Javascript. In javascript you can try
Code:
function integerToHex(number) {
	var hex_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
	// the output, supports only 32-bit integers
	var out = ['0', '0', '0', '0', '0', '0', '0', '0'];
	var len = out.length;
	for (var i = 0; i < len; i++) {
		var n = number >> 4;
		out[len - i - 1] = hex_chars[number - (n << 4)];
		number = n;
	}
	
	return "0X" + out.join("");
}

trace(integerToHex(-1324));
Reply With Quote
  #3 (permalink)  
Old 03-13-2008, 01:21 AM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default Re: convert int to hex

Thanks
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:04 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.