package com.PustakaFlash.text
{
/**
* ...
* @author Ricko
* imort com.PustakaFlash.text .*;
* XmlberWarna.xmlkpala="quis";
XmlberWarna.kpalawarna=0xFF9900;
XmlberWarna.defaultFormat = 0xFFFFFF;
XmlberWarna.commentFormat = 0x999999;
XmlberWarna.tagFormat = 0x00CC00;
XmlberWarna.cdataFormat = 0xFF9900;
XmlberWarna.attributeFormat = 0x0066FF;
XmlberWarna.Formatvar=0xFFFF00;
XmlberWarna.colorize(mc.tes);
*/
public class XmlberWarna
{
import flash.text.*;
// awal jika blum di sett
private static var tagkepala:TextFormat = new TextFormat('Arial', null, 0x999999,true);
private static var a:TextFormat = new TextFormat('Arial', 12, 0x000000);
private static var b:TextFormat = new TextFormat(null, null, 0x999999,true);
private static var c:TextFormat = new TextFormat(null, null, 0xCC0000,true);
private static var d:TextFormat = new TextFormat(null, null, 0x00CC00);
private static var e:TextFormat = new TextFormat(null, null, 0x0000CC,true);
private static var f:TextFormat = new TextFormat(null, null, 0xFFFFFF);
// awl regwxExp jika blum disett
private static var tgkpla: RegExp ;
private static var ar: RegExp = /(<[^/gs;
private static var brr: RegExp = //g;
private static var dr: RegExp = /[a-z0-9_]*=|[a-z0-9_]*=/gi;
private static var er: RegExp = /)/gs;
private static var fr: RegExp = /"(.*?)"|'(.*?)'/gi;
// sets the format for normal text di dalam xml
public static function set defaultFormat(v:*) : void
{
if (v is TextFormat)
{ a = v as TextFormat; return void; }
a.color = v;
}
public static function get defaultFormat() : TextFormat
{
return a;
}
// sets the format for comment text di XML
public static function set commentFormat(v:*) : void
{
if (v is TextFormat)
{ b = v as TextFormat; return void; }
b.color = v;
}
public static function get commentFormat() : TextFormat
{
return b;
}
// sets the format for tags di XML
public static function set tagFormat(v:*) : void
{
if (v is TextFormat)
{ c = v as TextFormat; return void; }
c.color = v;
}
public static function get tagFormat() : TextFormat
{
return c;
}
// sets the format for CDATA tags di XML
public static function set cdataFormat(v:*) : void
{
if (v is TextFormat)
{ d = v as TextFormat; return void; }
d.color = v;
}
public static function get cdataFormat() : TextFormat
{
return d;
}
// sets the format for CDATA tags di XML
public static function set attributeFormat(v:*) : void
{
if (v is TextFormat)
{ e = v as TextFormat; return void; }
e.color = v;
}
public static function get attributeFormat() : TextFormat
{
return e;
}
// sets the format for var tags di XML
public static function set Formatvar(v:*) : void
{
if (v is TextFormat)
{ f= v as TextFormat; return void; }
f.color = v;
}
public static function get attributeFormatvar() : TextFormat
{
return f;
}
public static function set kpalawarna(v:*) : void
{
if (v is TextFormat)
{ tagkepala= v as TextFormat; return void; }
tagkepala.color = v;
}
public static function get kpalawarna() : TextFormat
{
return tagkepala;
}
//set tag kepala
public static function set xmlkpala(v:*) :*
{
{tgkpla = new RegExp("\<" + v+ "(.*?)\>|\<\/" + v + "\>","gi");}
}
public static function get xmlkpala() :*
{
return tgkpla;
}
public static function colorize(_txt: TextField) : void
{
_txt.setTextFormat(a);
var txt: String = _txt.text;
var match: Object;
// this colors tags
match = ar.exec(txt);
while (match != null)
{
_txt.setTextFormat(c, match.index, match.index + match[0].length);
match = ar.exec(txt);
}
// this colors CDATA start tags
match = brr.exec(txt);
while (match != null)
{
_txt.setTextFormat(d, match.index, match.index + match[0].length);
match = brr.exec(txt);
}
// this colors CDATA end tags
match = cr.exec(txt);
while (match != null)
{
_txt.setTextFormat(d, match.index, match.index + match[0].length);
match = cr.exec(txt);
}
// this colors attributes
match = dr.exec(txt);
while (match != null)
{
_txt.setTextFormat(e, match.index, match.index + match[0].length);
match = dr.exec(txt);
}
// this colors multi-line comments
match = er.exec(txt);
while (match != null)
{
_txt.setTextFormat(b, match.index, match.index + match[0].length);
match = er.exec(txt);
}
// this colors var
match = fr.exec(txt);
while (match != null)
{
_txt.setTextFormat(f, match.index, match.index + match[0].length);
match = fr.exec(txt);
}
match = tgkpla.exec(txt);
while (match != null)
{
_txt.setTextFormat(tagkepala, match.index, match.index + match[0].length);
match = tgkpla.exec(txt);
}
}
}
}
WHAT'S NEW?
Loading...
Xml berwarna class as3
- Judul : Xml berwarna class as3
- Penulis : PF studio
- Kategori : Archive Code Snippets
-
Rating : 100% based on 10 ratings. 5 user reviews.
Item Reviewed: Xml berwarna class as3
9 out of 10 based on 10 ratings. 9 user reviews.
facebook
twitter
google+
fb share