- Voici un fonction qui décode les (mots) de votre choix en lui passant en paramètre le nom du champ texte sur lesquel procéder.
- Champ texte en effet, puisqu'en AS2 nous n'avons à disposition que l'instruction "ReplaceText".
-
- - Concernant la recherche d'occurences et son remplacement en AS3, je vous renvoie ici :
-
- http://livedocs.adobe.com/flash/9.0_fr/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts_bak&file=00000084.html
-
-
- this.createTextField("my_txt2", this.getNextHighestDepth(), 8, 150, 320, 22);
- my_txt2.autoSize = true;
- my_txt2.text = "'|à|'|â|'|€|,<b>machin</b>,|%|&|";
- Decode_carrets(my_txt2);
-
- my_txt.text = "'|à|'|â|'|€|,<b>machin</b>,|%|&|";
-
- Decode_carrets(my_txt);
-
- //------------------------------------------------------------------------------------
- function Decode_carrets(chaine){
-
- //Tableau contenant le code à rechercher et celui qui sera son remplaçant.
- var Tab_code = new Array ( ["'", "'"],
- ["&" , "&"],
- [",<" , "<"],
- [">," , ">"]
- );
- for(i=0; i<Tab_code.length; i++){//recherche avec tous les codes un par un
- var masq : String = new String(Tab_code[i][0]);
- var replace : String = new String(Tab_code[i][1]);
- var len_masq : Number = Tab_code[i][0].length;
- var pos_deb : Number = chaine.text.indexOf(masq);
- while (pos_deb >-1){ //recherche du même code sur la ligne entière
- chaine.replaceText(pos_deb, pos_deb+len_masq, replace);
- var pos_deb : Number = chaine.text.indexOf(masq);
- }//while
- }//for
-
- }
- //------------------------------------------------------------------------------------
Voici un fonction qui décode les (mots) de votre choix en lui passant en paramètre le nom du champ texte sur lesquel procéder.
Champ texte en effet, puisqu'en AS2 nous n'avons à disposition que l'instruction "ReplaceText".
- Concernant la recherche d'occurences et son remplacement en AS3, je vous renvoie ici :
http://livedocs.adobe.com/flash/9.0_fr/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts_bak&file=00000084.html
this.createTextField("my_txt2", this.getNextHighestDepth(), 8, 150, 320, 22);
my_txt2.autoSize = true;
my_txt2.text = "'|à|'|â|'|€|,<b>machin</b>,|%|&|";
Decode_carrets(my_txt2);
my_txt.text = "'|à|'|â|'|€|,<b>machin</b>,|%|&|";
Decode_carrets(my_txt);
//------------------------------------------------------------------------------------
function Decode_carrets(chaine){
//Tableau contenant le code à rechercher et celui qui sera son remplaçant.
var Tab_code = new Array ( ["'", "'"],
["&" , "&"],
[",<" , "<"],
[">," , ">"]
);
for(i=0; i<Tab_code.length; i++){//recherche avec tous les codes un par un
var masq : String = new String(Tab_code[i][0]);
var replace : String = new String(Tab_code[i][1]);
var len_masq : Number = Tab_code[i][0].length;
var pos_deb : Number = chaine.text.indexOf(masq);
while (pos_deb >-1){ //recherche du même code sur la ligne entière
chaine.replaceText(pos_deb, pos_deb+len_masq, replace);
var pos_deb : Number = chaine.text.indexOf(masq);
}//while
}//for
}
//------------------------------------------------------------------------------------