I'm trying to format code so that when it is displayed in a results window, it will be blue for keywords, gray for comments, and red for strings, similar to what Flash does when you write Action Script.
However, I'm having some troubles, and nothing seems to work. What am I doing wrong? Note that this is just a first draft, and still needs to be modified so that it does not highlight "to" in "stop".
public function CodeHTML():String { var HTML_Code:String = Code;
//These reserved words were all found in the Adobe Programming Action Script 3 Help reference var ReservedWords:RegExp = /(as|break|case|catch|class|const|continue|default|delete|do|else|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|to|true|try|typeof|use|var|void|while|with)/ HTML_Code = HTML_Code.replace(ReservedWords, "<span style=\\"color: #3300ff\\">$1</span>" //Blue
I checked on the AS3 LaCR (Language and Components Reference), and you are correct, Captain. The correct syntax is to use <font color='#FFFFFF'></font>
However, now I have run into another snag.
When I use the trace statement, I get this result:
Now I only have one problem left (which isn't really a priority). Keywords, such as of, as, if, etc, show up in blue, even when in the comments. Is there any way to get around this?
One way is to replace all comments with something like <com001>, <com002>, <com003>, and then later go back and replace all of those with the actual values stored in arrays, but is there any better or easier way to do this?