We Recommend

Beginning XML Beginning XML
The perfect resource for beginning XML programmers, this guidebook shows you what XML is, how to use it, and what technologies surround it. The authors build on the strengths of previous editions while covering the latest changes in the XML landscape such as XQuery, RSS and Atom, and Ajax.


Posted By

dandyna on 09/07/06


Tagged

actionscript replace text substitute


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

damarev
dandyna
visualAesthetic


Replace function on text strings


Published in: ActionScript 


Builds a function which replace some caracters

  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 

You need to login to post a comment.