Layout XML – To embed or not to embed

I’ve been thinking a few things out on a dynamic layout engine written in xml. Flex mxml layouts are all precompiled. This makes it faster at loading, however it makes the layout xml not reside on disk which therefore makes it harder who do not know flex to make modifications.

We recently wrote an entire actionscript 2.0 layout engine which was an enormous amount of work, but we achieved the point of having other developers make modifications to the xml without them having to know the entire flex framework. So it was pretty cool.

But, the question is – what are the advantages and disadvantages of doing a new layout engine for flash 9 cs3. Is it worth it? My problem with the flex framework is that the movies always seem over bloated some times.

As an example, the actionscript 2.0 layout engine, the core layout code ended up being 60k, for full HBox, VBox, widget set.

What do you think?

Actionscript 3 – Moving over to the darkside now that FDT 3 is out

Man, I want to move over to actionscript 3, but I still can’t do it yet. I have so much proficiency with actionscript 2 for the last 4 years that I can’t do it yet. I’m so used to it.

I want to do 3, but it seems like I have such a cool workflow right now with what I got, events, separation of responsibilities, that moving over to 3 seems like a waste of time. I mean, obviously I could do it, but the penetration isnt right yet. What do you think?

I’m also a bit weary because flash 9 cs3 still has issues. It’s not fully developed past 9.0.45 – if it had more penetration then I might jump over to using 3 and start fully developing in 3 now. But the component set in flash 9 cs3 only works with a player version as of a couple months ago.

I think the main jump that will push me over is now that FDT 3 is out I might start going hardcore actionscript 3 now.

The only thing I really liked about actionscript 2 was that FDT was so awesome and there were no bugs I couldn’t figure out in as2 – it’s just like everything could be overcome. It seems like because we’re building on an existing framework with flash 9 cs3 it might get a bit complicated. I’ve already seen some weird posts on flash 9 cs3 and no web service support that it’s not really worth it yet.

What are your guys thoughts?

Styling with CSS and XML – Actionscript translations

One thing which I found in dealing with all of the flash 8 and flex projects is that in translations for styling of CSS and XML – I’ve found a pretty effective way to do this so that in projects you can have a stylesheet applied with variable font sizes and XML being parsed at the same time.

It starts out with the fact that you have a TextLoader class which loads in the text similar to:

public static function loadText( aStyleSheetPath:String, anInterfaceDir:String ):Void
Logger.log("INFO", TextLoader.toString() + " loading stylesheets and text.");
var styleSheetDir:String = aStyleSheetPath;
var interfaceDir:String = anInterfaceDir;
var currentLanguage:String = LanguageManager.getLanguage();
var cssFilePath:String = styleSheetDir + "stylesheet_" + currentLanguage + ".css" ;
var xmlFilePath:String = interfaceDir + "interface_" +currentLanguage+".xml";

* Now we load in the stylesheet and once it is loaded we can then
* get the current interface and load this.

var stylesheet:TextField.StyleSheet = new TextField.StyleSheet();
stylesheet.load( cssFilePath );
stylesheet.onLoad = Delegate.create(TextLoader, function( status ) {
* Once the stylesheet is loaded we then apply this to the text and
* then get it applied and the text loaded.

var interfaceTextXml:XML = new XML();
interfaceTextXml.ignoreWhite = true;
interfaceTextXml.load( xmlFilePath );
interfaceTextXml.onLoad = Delegate.create(TextLoader, function( isLoaded:Boolean ) {
if( isLoaded ) {
Logger.log("INFO", TextLoader.toString() + "Interface XML loaded ["+ xmlFilePath+"] " );
Logger.log("INFO", TextLoader.toString() + "StyleSheet CSS loaded ["+cssFilePath+"] " );
TextLoader.initialize(interfaceTextXml, stylesheet);
TextLoader.notifyListeners( new TextLoadedEvent() );
} else {
Logger.log("ERROR", TextLoader.toString() + "Unable to load xml ["+xmlFilePath+"] " );


This then loads in a stylesheet and an xml file. Then once the class loads I dispatch a notifyListeners event which then lets all other classes know that the stylesheet and xml are loaded.

I then make any listeners implement the right events.

The TextLoader class then has a method called renderText which then looks like the following:

public static function renderText( t:TextField, textFromXML:String, aTextId:String ):Void {
var cssEntry:String = "";
var defaultFont:String = "ID_DefaultFont";
t.styleSheet = styleSheet;

if( aTextId.indexOf("_he") == -1 )
t.embedFonts = true;
} else {
t.embedFonts = false;

t.html = true;
t.multiline= true;
* Do a check if this particular class exists, if it doesn't then don't apply
* the class.
cssEntry = ( styleSheet.getStyle( "."+ aTextId ) != undefined ) ? "class='"+aTextId+"'" : "" ;

* Check if the active language is hebrew and forward this to the hebrew
* parsing engine to reverse the text.
if( LanguageManager.getLanguage() == "he" )
t.embedFonts = false;
if( styleSheet.getStyle( "."+defaultFont ) && (styleSheet.getStyle( "."+ aTextId ) == undefined) ) {
t.htmlText = Hebrew.getConversion( textFromXML, t, defaultFont );
} else {
t.htmlText = Hebrew.getConversion( textFromXML, t, aTextId );
//Logger.log("DEBUG", "TextLoader().renderText - Hebrew ["+t.htmlText+"] ");

// If there is a default font, set it to this but not if there is already
// a style defined.
if( styleSheet.getStyle( "."+defaultFont ) && (styleSheet.getStyle( "."+ aTextId ) == undefined) ) {
cssEntry = "class='"+defaultFont+"'";

t.htmlText = "

" + textFromXML + "

//Logger.log("INFO", "TextLoader().renderText - cssStyle ["+t.htmlText+"] ["+aTextId+"] ");

public static function getText( aTextId:String ):String {
return interfaceXML['idMap'][ aTextId ].firstChild.nodeValue.toString();

This allows for the renderText to then be used like TextLoader.renderText() which can then render the text applying the stylesheet similar to

— this then allows for a stylesheet to have an exact id applied to it.

This is pretty organized. Not bad a for a scientology coder, eh?

New image processing library

A new image processing library written in actionscript 3 was released. This includes very nice libraries for imaging effects, including displacement map filtering, ripples to create water effects. Joe Ebert is very talented at this which is great. The above image was created with this image processing library which is cool.

I’m very anxious to get down at try some of these effects. He actually made a really cool actionscript 3 demo a while back no doubt using this library.

Check it out here

Thoughts about flash design

One of the things that I actually like about flash is the fact that it allows you take programming and mesh it with design. This is something that is very hard to do with programs currently in a development atmosphere. You can take flash and create a piece of art and design that totally defies anything a programmer would do and you can also meld in something that allows for a total flexibility in programming and art combined.

I specifically am a large avid of very good design and animation which is what I like to see. And in my web log I will be posting in code samples and future things I come across later on.

One site I really like is which has a lot of great links. I’m also interested in flex and really like this technology and have used it in quite a few projects which I will brief on as well.