Styling your text with CSS in Actionscript 3

I know, it’s a very silly stuff, but I think could be useful for anybody that would like to styling textfields with CSS in few moments.
This little sample, show you how to make it via Actionscript 3 in Flash. 

First of all we create CSS file called cssStyle.css with a custom color for the text:

 .customBold{

color:#FF00CC;

}

Ok now, in the first frame of our Flash file we create a dynamic textfield with t_txt istance name and then we create another layer called “actionscript”. In the first keyframe of Actionscript layer we copy and past this code:

stop();


var loader:URLLoader = new URLLoader();

var req:URLRequest = new URLRequest(“cssStyle.css”);

loader.load(req);



loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);


function loaderCompleteHandler(event:Event):void {

var sheet:StyleSheet = new StyleSheet();

sheet.parseCSS(loader.data);

t_txt.styleSheet = sheet;

t_txt.htmlText = “<span class=’customBold’>This is a silly text with CSS style</span> and without CSS!”;

}

So first of all we load the external CSS file with URLLoader class and when loaded complete we use StyleSheet object to parse CSS and to apply it in our textfield in the stage we only set stylesheet textfield property with StyleSheet object.
You can download sample files from this link 

I become Adobe Certified Expert on Flex 3 with AIR, I suggest how to prepare the exam

Today I become ACE on Flex 3 with AIR… I’m so happy!!!
I’d like to suggest some stuff, to prepare Flex 3 ACE exam to help other developers that would try this… experience.

First of all download ACE PDF file where you can find exam outlines on adobe.com site.

Then start you preparation reading Flex 3: Training from the source, the official Adobe press book, I know that it could be so easy for advanced developers but you can find interesting stuff that go in deep about particular arguments.

Another PERFECT resources are Adobe documentations that explain very well and very easily how to use Flex and Adobe AIR API, in particular for AIR the best official stuff is Adobe livedocs.
I suggest to take also others books about AIR because you must remember a lots of things for the exam, so take a look at amazon.com 

Work Work and Work again with Flex! Find little or big projects, it’s not important but you can work in real problem solving issue. Also it’s so important to fix many concepts about how to work with modules, components and so on.

When I was at San Francisco MAX I went to Blaze DS and LiveCycle pre-event and it was very helpful for my preparation because LCDS is a part of exam and I’ve never take in consideration before this learning session, so I think you can take a course about LCDS in your country or town.

When you finish with all those steps you are ready to take the exam and maybe to pass it!

Feel free to comment this post with any questions.