Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1815 connectés 

  FORUM HardWare.fr
  Programmation
  Flash/ActionScript

  Affichage de caractères polonais depuis un xml

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Affichage de caractères polonais depuis un xml

n°2008082
Pascal le ​nain
Posté le 08-07-2010 à 15:57:23  profilanswer
 

Bonjour,
 
J'ai une timeline en flash que je n'ai pas codé moi-même, ne connaissant quasiment rien au flash.
Les données viennent d'un fichier xml.
Le fichier xml est encodé en UTF-8 avec notepad++.
Le header est spécifié en UTF-8.
 

<?xml version="1.0" encoding="UTF-8"?>


 
Je veux maintenant faire une version polonaise de la timeline.
Pour le xml, pas de problème, je peux écrire tous les caractères polonais (ę , ó , ą , ...)
Les caractères s'affichent bien si je lis le xml directement par mon navigateur.
Par contre lors de l'affichage dans l'animation flash, tous les caractères bizarres sont ignorés. Exemple : prowadzący devient prowadzcy.
 
Voici mon code brut. Excusez-moi de ne pas avoir isolé les parties importantes, car je n'ai aucune idée desquelles elle sont  :sweat:

Code :
  1. stop ();
  2. //import flash.system.System;
  3. //system.usecodepage = true;
  4. Stage.align = "TL"
  5. Stage.scaleMode = "noScale";
  6. //
  7. //variables
  8. var totalClipNumber : Number;
  9. var currentYear : Number = 0;
  10. var myData : Array = new Array ();
  11. var container : MovieClip = this.createEmptyMovieClip ("container", this.getNextHighestDepth ());
  12. var bl : MovieClip = this.createEmptyMovieClip ("bl", this.getNextHighestDepth ());
  13. var br : MovieClip = this.createEmptyMovieClip ("br", this.getNextHighestDepth ());
  14. //
  15. _global.setStage = function ()
  16. {
  17.     sliding = new Object ();
  18.     sliding.onResize = function ()
  19.     {
  20.         removeMovieClip (masca);
  21.         removeMovieClip (hmenu);
  22.         createMask ();
  23.         createHMenu ();
  24.         bLeft._x = 0;
  25.         bLeft._y = Stage.height - 20;
  26.         bRight._x = Stage.width - 40;
  27.         bRight._Y = Stage.height - 20
  28.     }
  29.     Stage.addListener (sliding);
  30.     sliding.onResize ();
  31. }
  32. ////
  33. setStage ();
  34. ///
  35. myXML = new XML ();
  36. myXML.ignoreWhite = true;
  37. myXML.load ("content.xml" );
  38. myXML.onLoad = function (_status)
  39. {
  40.     if (_status)
  41.     {
  42.         xmlItems = myXML.firstChild.childNodes;
  43.         totalClipNumber = xmlItems.length;
  44.         for (var i = 0; i < totalClipNumber; i ++)
  45.         {
  46.             myData.push (new Info (xmlItems [i].attributes.year, "images/" + xmlItems [i].attributes.pic, xmlItems [i].attributes.text));
  47.         }
  48.         buttonEvents ();
  49.         loadingMenuItems ();
  50.         attachText (0);
  51.         dataLoad (0);
  52.         scrolling ();
  53.     }
  54. };
  55. ///
  56. //
  57. //initialising button events
  58. buttonEvents = function ()
  59. {
  60.     bLeft.swapDepths(bl);
  61.     bRight.swapDepths(br);
  62.     removeMovieClip(bl);
  63.     removeMovieClip(br);
  64.     //
  65.     bLeft.onRelease = bLeft.onReleaseOutside = function ()
  66.     {
  67.         if (hmenu._x + 30 < 40)
  68.         {
  69.             hmenu._x += 30;
  70.         }
  71.         else
  72.         {
  73.             if (hmenu._x < 40)
  74.             {
  75.                 hmenu._x = 40;
  76.             }
  77.         }
  78.     }
  79.     bRight.onRelease = bRight.onReleaseOutside = function ()
  80.     {
  81.         if (hmenu._x - 30 > Stage.width - totalClipNumber * 30 - 40)
  82.         {
  83.             hmenu._x -= 30;
  84.         }
  85.         else
  86.         {
  87.             if (hmenu._x > Stage.width - totalClipNumber * 30 - 40)
  88.             {
  89.                 hmenu._x = Stage.width - totalClipNumber * 30 - 40;
  90.             }
  91.         }
  92.     }
  93. }
  94. //
  95. loadingMenuItems = function ()
  96. {
  97.     for (var i = 0; i < totalClipNumber; i ++)
  98.     {
  99.         var itemh = hmenu.attachMovie ("itemH", "year" + i, i ,
  100.         {
  101.             _x : 30 * i, _y : 0
  102.         });
  103.         itemh.h_text.text = myData [i].year;
  104.         itemh.loc = i;
  105.         //initialising events
  106.         itemh.onRollOver = function ()
  107.         {
  108.             if (currentYear != this.loc)
  109.             {
  110.                 this.itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
  111.             }
  112.         }
  113.         //
  114.         itemh.onRollOut = function ()
  115.         {
  116.             if (currentYear != this.loc)
  117.             {
  118.                 this.itemHMask.tween ("_y", 20, 1, "easeOutCubic" );
  119.             }
  120.         }
  121.         //
  122.         itemh.onRelease = itemh.onReleaseOutside = function ()
  123.         {
  124.             if (currentYear != this.loc)
  125.             {
  126.                 container.tween ("_x", 0 - container ["t" + this.loc]._x, 2, "easeOutExpo" );
  127.                 hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
  128.                 currentYear = this.loc;
  129.             }
  130.         }
  131.         //
  132.         
  133.     }
  134.     /////
  135.     hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
  136. }
  137. //////// creating the mask
  138. function createMask ()
  139. {
  140.     this.createEmptyMovieClip ("masca", 300);
  141.     masca._x = 0;
  142.     masca._y = 0;
  143.     masca.beginFill (0x000000, 100);
  144.     masca.lineTo (Stage.width, 0);
  145.     masca.lineTo (Stage.width, Stage.height - 20);
  146.     masca.lineTo (0, Stage.height - 20);
  147.     masca.lineTo (0, 0);
  148.     masca._alpha = 0;
  149. }
  150. //
  151. ///// creating the menu
  152. function createHMenu ()
  153. {
  154.     this.createEmptyMovieClip ("hmenu", 298);
  155.     hmenu._x = 40;
  156.     hmenu._y = Stage.height - 20;
  157.     hmenu.beginFill (0xFFFFFF, 100);
  158.     hmenu.lineTo (Stage.width - 80, 0);
  159.     hmenu.lineTo (Stage.width - 80, 20);
  160.     hmenu.lineTo (0, 20);
  161.     hmenu.lineTo (0, 0);
  162.     this.createEmptyMovieClip ("hmenuMask", 299);
  163.     hmenuMask._x = 40;
  164.     hmenuMask._y = Stage.height - 20;
  165.     hmenuMask.beginFill (0x667E38, 100);
  166.     hmenuMask.lineTo (Stage.width - 80, 0);
  167.     hmenuMask.lineTo (Stage.width - 80, 20);
  168.     hmenuMask.lineTo (0, 20);
  169.     hmenuMask.lineTo (0, 0);
  170.     hmenu.setMask (hmenuMask);
  171.     loadingMenuItems ();
  172. }
  173. /////// scrolling function
  174. scrolling = function ()
  175. {
  176.     this.onEnterFrame = function ()
  177.     {
  178.         xval = _xmouse;
  179.         yval = _ymouse;
  180.         ///
  181.         if (masca.hitTest (xval, yval, true) == true)
  182.         {
  183.             d = Math.cos (((masca._xmouse) / masca._width) * Math.PI) * 15;
  184.             if (d < 0)
  185.             {
  186.                 if (masca._width / 2 - container ["t" + (currentYear + 1)]._x > container._x)
  187.                 {
  188.                     hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
  189.                     currentYear ++;
  190.                     hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
  191.                 }
  192.             }
  193.             else
  194.             {
  195.                 if (masca._width / 2 - container ["t" + currentYear]._x < container._x)
  196.                 {
  197.                     hmenu ["year" + currentYear].itemHMask.tween ("_y", 20,.5, "easeOutCubic" );
  198.                     currentYear --;
  199.                     hmenu ["year" + currentYear].itemHMask.tween ("_y", 0,.5, "easeOutCubic" );
  200.                 }
  201.             }
  202.         }
  203.         else
  204.         {
  205.             d = 0;
  206.         }
  207.         container._x += d;
  208.         if (container._x > masca._x)
  209.         {
  210.             container._x = masca._x;
  211.         }
  212.         if (container._x < (masca._x - (container._width - masca._width)))
  213.         {
  214.             container._x = masca._x - (container._width - masca._width);
  215.         }
  216.     };
  217. };
  218. //
  219. // load data on stage function
  220. dataLoad = function (picNr)
  221. {
  222.     var my_mcl : MovieClipLoader = new MovieClipLoader ();
  223.     var mclListener : Object = new Object ();
  224.     mclListener.onLoadError = function (target_mc : MovieClip, errorCode : String, status : Number)
  225.     {
  226.     };
  227.     mclListener.onLoadStart = function (target_mc : MovieClip) : Void
  228.     {
  229.     };
  230.     mclListener.onLoadProgress = function (target_mc : MovieClip, numBytesLoaded : Number, numBytesTotal : Number) : Void
  231.     {
  232.     };
  233.     mclListener.onLoadComplete = function (target_mc : MovieClip, status : Number) : Void
  234.     {
  235.     };
  236.     mclListener.onLoadInit = function (target_mc)
  237.     {
  238.         if (picNr < totalClipNumber - 1)
  239.         {
  240.             if (myData [picNr + 1].picPath == "images/" )
  241.             {
  242.                 do
  243.                 {
  244.                     attachText (picNr + 1);
  245.                     picNr ++;
  246.                 }
  247.                 while (myData [picNr].picPath == "images/" );
  248.                 //
  249.                 dataLoad (picNr);
  250.             } else
  251.             {
  252.                 attachText (picNr + 1);
  253.                 picNr ++;
  254.                 dataLoad (picNr);
  255.             }
  256.         } else
  257.         {
  258.             //trace ("am terminat" );
  259.             
  260.         }
  261.     };
  262.     my_mcl.addListener (mclListener);
  263.     var imgholder : MovieClip = container.createEmptyMovieClip ("p" + picNr, picNr * 2);
  264.     imgholder._x = container._width;
  265.     my_mcl.loadClip (myData [picNr].picPath, container ["p" + picNr]);
  266. };
  267. //
  268. attachText = function (i)
  269. {
  270.     var itemt = container.attachMovie ("itemT", "t" + i, i * 2 + 1 ,
  271.     {
  272.         _x : container._width, _y : 0
  273.     });
  274.     itemt.title_text.text = myData [i].year;
  275.     itemt.text_text.text = myData [i].text;
  276. }


 
J'ai essayé, comme vous pouvez le voir d'activer "system.usecodepage", comme j'ai vu sur plusieurs forums, mais ca n'a rien changé. Mais d'après la doc flash, c'est en UTF-8 par défaut, donc je devrais pouvoir m'en passer.
 
Pourriez-vous m'aider à résoudre cet épineux problème ?
 
Merci d'avance  :hello:


Message édité par Pascal le nain le 08-07-2010 à 15:59:26
mood
Publicité
Posté le 08-07-2010 à 15:57:23  profilanswer
 

n°2009317
Pascal le ​nain
Posté le 15-07-2010 à 15:51:31  profilanswer
 

Up ;)

n°2009801
abais
Posté le 18-07-2010 à 18:20:29  profilanswer
 

Salut,
Je n'ai pas de "réel" solutions / explications à te donner, mais en "embeddant" les caractères de polices sur ton textfield dans l'API Flash, tu résoudra surement ton problème
=> Topic avec un screenshot de l'embed
(Sauf que toi tu mettras "All" pour être sûre d'avoir tous les Glyphes... au moins pour tester...)


Message édité par abais le 18-07-2010 à 18:25:47

---------------
Le membre ci-contre n'est pas responsable du message ci-dessus.

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Flash/ActionScript

  Affichage de caractères polonais depuis un xml

 

Sujets relatifs
PB affichage requete dans PHPFPDF - Affichage sous condition
[OpenGl] Choisir la bonne méthode d'affichage (Vertex Array ?)probleme caracteres UNIX-WINDOWS en php
fonction exec et affichage problème apparition fenetre dos[DELPHI] Verifier les caractères d'un string !
JTable , probleme affichageCaractères spéciaux
Mauvais affichage menu SPRY sous IERemplacement d'un motif dans une chaine de caractères
Plus de sujets relatifs à : Affichage de caractères polonais depuis un xml


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR