caracteres speciaux sous flash
bonjour tout le monde,
J'ai codé une classe en AS qui charge tous les caracteres speciaux et les affiche dans un MovieClip.
Le probleme est que certains caracteres ne s'affichent pas mais plutot un carre s'affiche a la place.
C peut etre un prob d'encodage, mais je ne sais pas commenet m'y prendre.
j'ai essaye avec la methode embedFonts mais tjrs rien
Kelkun aurait une idee?
Voici ma classe, pour la tester creez un movieclip vide et appeler la methode drawTable(x:Number, y:Number).
Si vous avez une solution veuillez svp me la comminiquer.
Merci d'avance
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
class SpecialChar extends MovieClip {
private static var box_size = 25;
private var symbol:Array;
private var table:MovieClip;
private var xt, yt:Number;
private var xpos, ypos:Number = 0;
public var ourformat:TextFormat;
/*
/Constructor
*/
public function SpecialChar() {
}
/*
/ Drawing small boxes wich will contain the characters
*/
private function box(clip:MovieClip, x:Number, y:Number, s:String):Void {
clip.lineStyle(1, 0x8000ff, 100);
clip.moveTo(x, y);
clip.lineTo(x+SpecialChar.box_size, y);
clip.lineTo(x+SpecialChar.box_size, y+box_size);
clip.lineTo(x, y+SpecialChar.box_size);
clip.lineTo(x, y);
var tf:TextField = clip.createTextField("txtfld", clip.getNextHighestDepth(), x, y, 25, 25);
tf.text = s;
//tf.embedFonts = true;
ourformat.font = "Times New Roman";
ourformat.size = 12;
ourformat.bold = true;
ourformat.align = "center";
ourformat.color = 0x000000;
tf.setTextFormat(ourformat);
}
/*
/ Get the symbol corresponding to the given codes
*/
private function getSymbol():Void {
this.symbol = new Array();
for (var i = 0; i<255; i++) {
this.symbol.push(String.fromCharCode(i));
}
}
private function drawTable(x:Number, y:Number):Void {
this.getSymbol();
this.table = this.createEmptyMovieClip("tableChar", 10);
this.table._x = x;
this.table._y = y;
var xpos:Number = 0;
var ypos:Number = 0;
var ctr:Number = 0;
while (ctr<this.symbol.length) {
this.box(this.table, xpos, ypos, this.symbol[ctr]);
if ((xpos%(16*SpecialChar.box_size)) == 0 && (xpos != 0)) {
ypos += 25;
xpos = 0;
} else {
xpos += SpecialChar.box_size;
}
ctr++;
}
}
} |