[Extendflash] converting fill color to tint

Morten Barklund Shockwaved morten.barklund at shockwaved.com
Mon Aug 8 18:35:40 PDT 2005


Hi Till,

>> I've made a little workaround using a function, that converts the
>> six special characters, that my use is limited to, into their 
>> utf8-urlencoded entities.
> 
> Here's a trick from the bad old Flash MX days, when there was no way
> to encode AS files as utf8: Instead of url-encoding the characters,
> you can also utf8-escape them. The advantage is that utf8-escaped
> characters get decoded automatically when the script is read. (I
> think. Decoding might also happen when the bytecode is interpreted,
> but that's not of much practical difference, really.)
> 
> To encode a character as a utf8 escape sequence, you'll have to know
> the sequence, as there's - to my knowledge - no way to automatically
> do this. If you're working in Windows, you can find out the correct
> sequence for a character by using the Character Map (under Start /
> Programs / Accessories). If you select a character in that Tool, the
> escape sequence is shown in the lower left corner of the window.
> E.g., for the character "å" (I hope this doesn't get mangled by the
> all-mighty system that is global email communication ;-)), the
> sequence is "U+00E5". To encode the sequence, you replace the
> character by "\u" followed by the four digit escape sequence (in the
> case of "å" that would be "\u00e5").

The unicode of a character is just the charcode - thus:

var t:String = "æøåÆØÅא";
trace(t);
for (var i = 0; i < t.length; i++) {
	trace("\\u" + zero_pad(t.charCodeAt(i).toString(16)));
}
function zero_pad(str) {
	for (var i = str.length; i < 4; i++) {
		str = "0" + str;
	}
	return str;
}

Gives me the unicode version of these 7 characters - 6 danish characters 
and aleph - the ever-useful unicode example character :]

\u00e6
\u00f8
\u00e5
\u00c6
\u00d8
\u00c5
\u05d0

But that _is_ a nice trick - maybe I should do that in stead. And yes, 
the codes are converted to the characters compile-time (or actually, the 
regular characters and the coded characters are all converted to 
unicodes compile-time).

-- 
Morten Barklund - Information Architect - Shockwaved ApS
Larsbjoernsstraede 8 - DK-1454 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174


More information about the Extendflash mailing list