Ihr wolltet schon immer wissen was southpark-kenny so sagt, hier sind die entsprechenden Funktionen


:
ActionScript:
text="So ich hab jetzt zwei schöne Funktionen gebastelt und poste die mal einfach im OOP-Forum, mal sehen was dann kommt.";
kenny_it=function(text){
kenny="";
for(i=0;i<this.text.length;i++){
item=this.text.charAt(i);
if((item>="a" && item<="z")||(item>="A" && item<="Z")){
if(item>="a"){
offset=97;
}else{
offset=65;
}
char=((item.charCodeAt(0)-offset).toString(3));
if(char.length<3){
do {
char="0"+char;
} while (char.length<3);
}
for(j=0;j<3;j++){
n=char.charAt(j);
if(j==0 && offset==65){
kenny=kenny+["M","P","F"][n];
}else{
kenny=kenny+["m","p","f"][n];
}
}
}else{
kenny=kenny+item;
}
}
return (kenny);
}
kenny_said=function(text){
output="";
do{
item=text.charAt(0);
n="mpfMPF".indexOf(item);
if(n<>-1){
if(n>2){
upper=true;
n-=3;
}
for(i=0;i<2;i++){
text=text.substring(1,text.length);
char=text.charAt(0);
n=n*10+"mpf".indexOf(char);
}
item=String.fromCharCode(parseInt(n,3)+97);
if(upper){
item=item.toUpperCase();
upper=false;
}
}
text=text.substring(1,text.length);
output=output+item;
}while(text<>"")
return(output);
}
trace(kenny_it(text));
trace(kenny_said("Mffmmfmfp fppüpppfmmmmfmfpmpp Mppfmfmmfmfp mmmpmfpmfmppppp mppmffpppmppppp mfmfmffmpmppppp Pfffmffmpfmmmmfmfp mffpppfmm pppmppfmfmpp Pmmmmmmfppff!!!"));
Alois