I am really unexperienced when it comes to classes so bare with me. I decided to turn this util into a class because I use it in almost all of my projects. Basically what it is is I import an XML file and it has all these HTML characters like & or   and my function basically converts those strings of characters to its regular form ie: [’&’ (&)] or [’ ’ ( )]
so calling it in a FLA file would be something like this:
var entity:DeEntitizeHTML = new DeEntitizeHTML("bob & jim");
and here is my class file:
class com.dop.DeEntitizeHTML
{
function DeEntitizeHTML(my_str)
{
runStr(my_str);
}
private function runStr(my_str:String):String
{
var chars:Array = my_str.split("");
for (var i = 0; i < chars.length; i++)
{
if (chars* == "&")
{
var entity:String = "";
for (var j = 0, myChar = ""; myChar != ';'; j++)
{
var myChar:String = String(chars.splice(i, 1));
if (myChar == " ")
{
entity = "& ";
myChar = ';';
}
else
{
entity += myChar;
}
if (j > chars.length)
{
trace("OVERFLOW!!");
break;
}
}
chars.splice(i,0,swapEntityForChar(entity));
}
}
my_str = chars.join("");
return (my_str);
}
private function swapEntityForChar(myStr:String):String
{
switch (myStr)
{
case " " :
// CR
return ("
");
break;
case " " :
// non-breaking space
return (" ");
break;
case "&" :
return ("&");
break;
case "& " :
// special Kludge
return ("& ");
break;
case "•" :
// bullet
return ("•");
break;
case "≥" :
return ("≥");
break;
case ">" :
return (">");
break;
case "…" :
return ("…");
break;
case "“" :
return ('“');
break;
case "≤" :
return ("≤");
break;
case "‘" :
return ("‘");
break;
case "<" :
return ("<");
break;
case "−" :
return ("-");
break;
case "—" :
return ("—");
break;
case "–" :
return ("–");
break;
case "”" :
return ('”');
break;
case "’" :
return ("’");
break;
default :
return (" ");
}
}
}
I cant figure out how to return that value back to the var entity in my FLA. Any help please?