//t_txt.htmlText = new AsHighLighter(t_txt).highlight(); function AsHighLighter(txtObj,txtDat) { if (txtObj == null) { //alert("txtObj is null!"); return; } var styles = new TextField.StyleSheet(); styles.setStyle(".code", {fontFamily:'Courier New', fontSize:'12px'}); styles.setStyle(".keyword", {color:'#0000C1'}); styles.setStyle(".commonobject", {color:'#000080',fontWeight:"bold"}); styles.setStyle(".string", {color:"#6E6E6E"}); styles.setStyle(".comment", {color:"#FF8040"}); txtObj.styleSheet = styles; this._codetxt = txtDat.split("\n").join(""); this._keywords = "break,continue,case,delete,do,default,else,for,function,if,in,ifFrameLoaded,new,on,onClipEvent,return,switch,tellTarget,trace,var,while,with,#include,#endinitclip,#initclip"; this._commonObjects = "arguments,Accessibility,Array,Application,Boolean,Button,Color,CustomActions,Camera,Client,Date,false,Function,Key,LoadVars,LocalConnection,Math,Mouse,MovieClip,Microphone,null,newline,Number,NetConnection,NetStream,Object,super,Selection,Sound,Stage,String,System,SharedObject,Stream,true,this,TextField,TextFormat,undefined,Video,XML,XMLSocket"; this._wordDelimiters = " ,.?!;:/<>(){}[]\"'\n\t=+*%"; this.highlight = function() { var codeArr = new Array(); var word_index = 0; var htmlTxt = ""; for (var i = 0; i0) { word_index++; } codeArr[word_index++] = this._codetxt.charAt(i); } } var quote_opened = false; var slash_star_comment_opened = false; var slash_slash_comment_opened = false; var line_num = 1; htmlTxt += ("

"); for (var i = 0; i"+codeArr[i]+""); } else if (!slash_star_comment_opened && !quote_opened && this.isCommonObject(codeArr[i])) { //keyword htmlTxt += (""+codeArr[i]+""); } else if (codeArr[i] == "\n") { if (slash_slash_comment_opened) { htmlTxt += (""); slash_slash_comment_opened = false; } htmlTxt += ("
"); line_num++; } else if (codeArr[i] == "\"" && codeArr[i-1] != "\\") { if (slash_star_comment_opened) { htmlTxt += (codeArr[i]); continue; } if (quote_opened) { htmlTxt += (codeArr[i]+""); quote_opened = false; } else { htmlTxt += (""+codeArr[i]); quote_opened = true; } } else if (codeArr[i] == "/") { if (codeArr[i+1] == "*") { if (slash_slash_comment_opened || slash_star_comment_opened) { htmlTxt += (codeArr[i]); continue; } slash_star_comment_opened = true; htmlTxt += (""+codeArr[i]+codeArr[i+1]); i++; } else if (codeArr[i+1] == "/") { if (slash_star_comment_opened || slash_slash_comment_opened) { htmlTxt += (codeArr[i]); continue; } slash_slash_comment_opened = true; htmlTxt += (""+codeArr[i]+codeArr[i+1]); i++; } else { htmlTxt += (codeArr[i]); } } else if (codeArr[i] == "*") { if (codeArr[i+1] == "/") { if (slash_slash_comment_opened) { htmlTxt += (codeArr[i]); continue; } if (slash_star_comment_opened) { slash_star_comment_opened = false; htmlTxt += (codeArr[i]+codeArr[i+1]+""); i++; } } else { htmlTxt += (codeArr[i]); } } else if (codeArr[i] == "\t") { //keyword htmlTxt += ("    "); } else if (codeArr[i] == "<") { //keyword htmlTxt += ("<"); } else { htmlTxt += (codeArr[i]); } } htmlTxt += ("

"); return htmlTxt; }; this.isKeyword = function(val) { var keywordArr = this._keywords.split(","); for (var i = 0; i