January 12, 2009 1:48 PM

Beautiful code becomes even more beautiful when syntax highlighted. After getting a lot of requests for the code of the syntax highlighting part of sandboxviolation, I've decided to release that part as a free, open source component. as3syntaxhighlight is an AS3 library that supports syntax highlighting of code in a variety of programming languages including MXML and AS3. It can be used for syntax highlighting as you type or for generating HTML which can be applied as htmlText to a TextField or TextArea.

as3syntaxhighlight is an AS3 port of google-code-prettify's prettify.js with some additions and changes. It has support for recognizing AS3 within MXML1, colors "function" and "var" differently so that the statement "private function" looks like the way it would look in Flex Builder.

Also, I've added an "async" mode to it so that it can syntax highlight in chunks and won't block the UI when fed large amounts of code. The async mode uses Alex Harui's PseudoThread to figure out how much work can be done before the screen blocks.

Try it out by clicking the image below:

as3syntaxhighlight demo

To download, visit the google code project page.

In sandboxviolation, while posting a question or answer, you can mix code with text. The code sections have to be enclosed between [code] and [/code] and these parts are syntax highlighted using as3syntaxhighlight. Actually, as3syntaxhighlight was solely developed for sandboxviolation.

sandboxviolation Post Question view

This is one of the coolest features in sandboxviolation and it totally rocks when you can type in code and it gets syntax highlighted just like in an IDE.

CategoryFlex Comment(s)


[1] This was added recently to google-code-prettify as well.

Copyright © 2004-2011 Anirudh Sasikumar. All rights reserved.
Last Updated: January 12, 2009 6:06 PM