Estou mandando pra voces uma classe que pode fazer tudo o que a classe String faz mas com métodos adicionados, para facilitar a manipulacao de Strings no flash
Ela foi feita por mim com a ajuda do Maxwell Dayvson
Publicidade
|
|
Page 1 of 1
Classe para manipulacao de String flash mx 2004 na veia...
#1
Posted 01 June 2004 - 12:51 PM
| CODE |
/* Classe Str v1.0 feita para faciliar a manipulacao de Strings criada por Andrews Medina (cybermix) auxílio:Maxwell Dayvson */ dynamic class Str extends String { function Str(texto:String) { super(texto); } public function removeAcento():String { var x,str:String=this; var lista= {a:['á','ã','à','â'], e:['é','ê','è','ë'], i:['í','ì','ï','î'], o:['ó','ô','ò','õ'],u:['ú','ù','ü','û']}; for (x in lista) { for (var i:Number=lista[x].length; i--;) { str = str.split(lista[x][i].toUpperCase()).join(x.toUpperCase()); str = str.split(lista[x][i]).join(x); } } return(str); } public function replace(v:String, n:String):String { var r:String = this; r = r.split(v).join(n); return(r); } public function trim():String { var i:Number; var texto:String = this; for (i=0; texto.charAt(i) == " "; i++); texto = texto.substr(i, texto.length); for (i=texto.length-1; texto.charAt(i) == " "; i--); texto = texto.substr(0, i+1); return (texto); } public function ltrim():String { var i:Number; var texto:String = this; for (i=0; texto.charAt(i) == " "; i++); texto = texto.substr(i, texto.length); return (texto); } public function rtrim():String { var i:Number; var texto:String = this; for (i=texto.length-1; texto.charAt(i) == " "; i--); texto = texto.substr(0, i+1); return (texto); } public function inverte():String { var text:String = this; return(texto.split("").reverse().join("").toString()); } public function retEspacos():String { var texto:Str = new Str(this); return (texto.replace(" ", "")); } } |
Exemplo do seu uso:
| CODE |
import Str; var texto:Str = new Str(" Andrews medina é vicio em flash mx 2004 "); trace(texto.removeAcento()); trace("<"+texto.trim()+">"); trace("<"+texto.ltrim()+">"); trace("<"+texto.rtrim()+">"); trace(texto.replace("m", "Y")); trace(texto.inverte()); trace(texto.retEspacos()); //alguns metodos da classe string para verem como é legal =D trace(texto.indexOf("med", 0)); trace(texto.length); |
Share this topic:
Page 1 of 1
Similar Topics
| Topic | Forum | Started By | Stats | Last Post Info | |
|---|---|---|---|---|---|
|
Do Flash para o Jsp
MX Professional 2004 |
Flash & ActionScript |
Dolivermetal
|
|
|
|
Banner Flash
banner |
Flash & ActionScript |
Bruno Souza
|
|
|
|
Erramos: Jogos para meninas e "Naruto" são os termos de busca que mais cresceram no Google
|
Notícias |
Notícias
|
|
|
|
Monopoly ganha versão para Facebook
|
Notícias |
Notícias
|
|
|
|
Loja de aplicativos para Mac abrirá dia 6 de janeiro
|
Notícias |
Notícias
|
|
|
|
Olá amigos
Como fazer uma parada mais avançada... |
Flash & ActionScript |
cahe
|
|
|
|
Facebook testa ferramenta que cobra US$ 2 para promover post pessoal
|
Notícias |
Notícias
|
|
|
|
EUA aprova o PlayBook para suas agências federais
|
Notícias |
Notícias
|
|
Publicidade
|
|

Help













