All Posts in Flex

October 18, 2010 - No Comments!

Available Font List AS3

Quick little tip for displaying the fonts you have loaded into your AS3 project. Once the fonts have registered run this small script to trace out the fonts available to your application.

var fontArray:Array = Font.enumerateFonts(false);
for(var i:int = 0; i < fontArray.length; i++) { var font:Font = fontArray[i]; trace(“name: “ + font.fontName); trace(“typeface: “ + font.fontStyle); }

August 13, 2010 - 2 comments

Embedding Fonts in Flex Rich Text Editor

Over the last couple of days I've been playing with the Rich Text Editor component in Flex, however when trying to use embedded fonts the editor seemed to switch to a default font. It appears that if you want to want to use custom/ embedded fonts in your project you also need to include the default Flex font (Verdana) in your styles declaration.

The reasoning is that if Flex tries to use a font that is not embedded, it will automatically switch to the use of system fonts. By default the Rich Text Editor uses Verdana, so in turn if you don't embed or locate Verdana, Flex will ignore your embedded fonts and switch to default system fonts, now for the code...

src: url("assets/fonts/times.ttf");
font-family: Times;
advancedAntiAliasing: true;
U+0020-U+0040, /* Punctuation, Numbers */
U+0041-U+005A, /* Upper-Case A-Z */
U+005B-U+0060, /* Punctuation and Symbols */
U+0061-U+007A, /* Lower-Case a-z */
U+007B-U+007E; /* Punctuation and Symbols */

Read more

June 13, 2010 - No Comments!

Unit Testing with Flash Builder and Flex Unit 4

Over the last couple of days I've had some time to look into a few features of Flash Builder, one of the exciting ones being the inclusion of unit testing. After having a quick look at online examples I was running into a few issues finding a complete example using Flex Unit 4 within Flash Builder, so here is a quick overview to get you up and running based on a mixture of examples I have been playing with.

We start by building a new flex project, >File >New >Flex Project. For this example I will just name it UnitTestDemo, keep the other settings as default (i.e. Application type: web, SDK:Flex 4), hit Finish. Now lets create a class we will perform our tests on. Here is my example class, named TestObject.

public class TestObject
public function TestObject()
public function returnNumberOne():int
return 1;
public function returnString(value:String):String
return value;
public function returnTrue():Boolean
return true;

This is just a simple class with a few example functions which we will run our tests on, ok... now for our test class. >File >New >Test Case Class. Create a name for your class, in this case I have named it as TestClass, Flash Builder will create folder to place these into named flexUnitTests.

Read more

June 7, 2010 - No Comments!

Posting to Social Media – An Actionscript Perspective

As more clients understand and appreciate the contribution social media has to the success of their projects, it is becoming ever more a standard for the projects I undertake to include some form of share functionality. Some of you are probably aware of the early issues faced with 3rd party APIs when using them within the Actionscript side of the project, as opposed to the javascript of the the holding page.

Lets start with the more simple side of things where users simply want to share a simple link.



Add to Any

Those are just some of the basics. For a slightly different scenario, how about we have created a project where the user wishes to share a custom status alongside an image for example. You will see examples of this in your "News Feed" of your Facebook Account where friends may have shared games scores which also contain a link to the game and a small thumbnail image to promote the game or application.

Read more

May 7, 2010 - No Comments!

Memory Management in AS3 – A Quick Intro

As many of us know, memory management in any good size project is a topic that particular attention must be paid to. Over the last 12 months I have seen myself carrying out more and more research into memory management, in a recent project for example I was able to bring the memory usage of a website down by almost 30% in a matter of minutes by integrating simple techniques that I adopt in my own project builds.

In the words of Grant Skinner, "With great power comes great responsibility", and as we find ourselves building more complex applications it is important we consider  the internal Garbage Collector and help it carry out its chores. The understanding of the Garbage Collector is another topic in itself, this post is merely a few pointers which I use as a rule of thumb in my work flow.

General tips

  • Add an Event.REMOVED_FROM_STAGE listener to instance which calls in built function to tidy up assets for garbage collector
  • Use weak event listeners
  • Remove/ set to null any variables passed into the instance/ container
  • Set to null any strings contained by components e.g. label.text = null / image.src = null
  • Remove all children of the instance
  • Delete the instance i.e. delete this

Continued Reading