Replace function on text strings


/ Published in: ActionScript
Save to your folder(s)

Builds a function which replace some caracters


Copy this code and paste it in your HTML
  1. onClipEvent (load) {
  2. //associa replace, che abbiamo creato noi con una funzione a tutte le stringhe.
  3. String.prototype.replace = function(stringa, rep) {
  4. var temp_array = this.split(stringa);
  5. return temp_array.join(rep);
  6. };
  7. }
  8.  
  9.  
  10.  
  11.  
  12. //now, an example of use:
  13.  
  14.  
  15. onClipEvent (enterFrame) {
  16. if (fine == 1) {
  17. vel = 8;
  18. testo_app = new String(testo0);
  19. stringhe = new Array(new Array('*ec*', '&'), new Array("&", "&"), new Array("à", "à"), new Array("è", "è"), new Array("ì", "ì"), new Array("ò", "ò"), new Array("ù", "ù"), new Array("é", "é"));
  20. num_stringhe = stringhe.length;
  21. for (i=0; i<num_stringhe; i++) {
  22. testo_app = testo_app.replace(stringhe[i][0], stringhe[i][1]);
  23. }
  24. fine = 2;
  25. i = 0;
  26. l = testo_app.length;
  27. testo = " ";}
  28. if (fine == 2) {
  29. i=i+vel;
  30. if (i>l){i=l;
  31. fine=3;}
  32. testo = testo_app.substr(0, i);
  33. if (i == l) {
  34. fine = 4;
  35.  
  36. }
  37. }
  38. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.