Accueil > Lecture d'un fichier TXT externe avec accents |
version v2 |
05/01/2007 |
Eanim - Mtasc |
|
|
Cette démo à pour but de vous aider à afficher du texte
avec accents |
fichier batch ban.bat: E:\mtasc\mtasc -swf banniere.swf -main banniere.as pause fichier phi |
fichier
banniere.as: import MovieClip; import flash.TextField; class banniere{ static var intervalId:Number; static var donnees_xml = new XML(); static var flag:Number; static var my_fmt:TextFormat; static var cpte:Number; //================================================ function banniere() { if (flag != 11){ // init variables _root.message1_text="1"; // pour passage 1 fois au load flag=11;cpte =0; }; // fin if init intervalId = setInterval(this, "tempo", 1000);// tempo }; // fin fonction var_xml //--------------Timer -------------------------- function tempo(){ // ici vous pouvez mettre du prog qui sera éxécuté en permanence if (_root.message1_text != "2") { // ne pas executer si affichage terminé cpte = cpte +1; // juste pour tester avec eanim if (cpte >=99){ cpte = 0;} // juste pour tester avec eanim _root.cpt_text=String(cpte); // juste pour tester avec eanim //------------------------------------------------- donnees_xml.onLoad = function(ok) { if ((ok)&&(_root.message1_text=="1")) { // éxecute dès la fin chargement _root.contenu_text = this.toString(); // récup du fichier texte _root.message1_text="2"; //ne plus passer si terminé // =============== affichage texte ============================ var x:Number=140; var y:Number=2; // position du texte // si utilisation des codes html -------------- // rouge= '#FF0000' -bleu =#0000FF-vert=#00FF00 // texte centrer , en gras , police Arial var dcol:String="<p align='center'><b><font face='Arial' color='#0000FF' size='16'>"; // code début police + couleur var fcol:String="</font></b></p>"; // code fin police+couleur // si non utilisation des codes html ----------- _root.createTextField("my_txt", 999,x,y, 250, 300); _root.my_fmt = new TextFormat(); _root.my_fmt.bold = true; // true=gras false=normal _root.my_fmt.italic = false; // true=italic false=normal _root.my_fmt.font = "Arial"; // choix de la police _root.my_fmt.embedFonts = true; _root.my_fmt.size = 13; // TAILLE _root.my_txt.setNewTextFormat(_root.my_fmt); _root.my_txt.textColor =0xFF9900; // couleur FF9900 orange _root.my_txt.leading = -10; // interlignage ?? //==== choix codes html donc =true sinon =false _root.my_txt.html = true; // false true _root.my_txt.htmlText =dcol+_root.contenu_text+fcol; //=> mettre // si choix non html //==== choix codes non html //_root.my_txt.text = _root.contenu_text; //=>enlever // si choix non html }; // FIN IF OK }; // FIN IF FONCTION OK donnees_xml.load('datas.txt');// fichier a charger } // fin if message1 }; // fin tempo //------------------------------------- static function main() { var t = new banniere();} } // fin de la class |