Michael J.A. Clark
Michael Clark is a Computer Science student from England providing freelance programming and design when not studying at Cambridge. Skills: C#, Sitecore, PHP, XHTML, CSS, AS3, Java, ML, F#.

Sections

Contact details

Email
mjac@mjac.co.uk
Skype
mjacdotuk
Twitter
mjacuk

Articles tagged features

Useful resources for Flex AS3

I recently spent a summer creating Adobe Flash applications for Kickstart Digital using the Flex framework. Back in my teenage years I spent a lot of time creating pseudo-agencies with flashy adverts (Flash 4/5/MX). It has progressed incredibly since then.

AS3 is a respectable, highly featured language. Flash is capable and still has a place in development. I cannot imagine developing for it without Adobe Flash Builder 4. Until a widely adopted Javascript/Canvas IDE is developed, Flash will have a place delivering rich media on the web.

Starting out

Essential resources include the Spark components and complete list of Flex 4 classes. Learning how to handle exceptions is essential as much of development time is spent testing. Bugs are inevitable after all.

These resources should be bookmarked before embarking on a Flex adventure. It is important to use the latest Spark components such as s:BitmapImage instead of older mx:Image components. Some tutorials can now be improved using Spark components.

The program can attach events to the UI lifecycle. Common attachment attributes include preInitialize, initialize, creationComplete and applicationComplete. I use initialise the most, placing the handler before dimensions are calculated but after all child components have been initialised first.

Layouts

By default spark groups position children using absolute coordinates. Other layouts can be assigned using the spark layout element:

<s:Group>
    <s:layout>
        <s:HorizontalLayout />
    <s:layout>
</s:Group>

Prefer to use inbuilt element abbreviations. A large amount of interfaces can be created using just these three component containers.

<s:HGroup />
<s:VGroup />
<s:TileGroup />

Each group can have a default alignment for child components. Gap is the name for spacing in Spark components as is an extremely useful attribute.

Data structures

AS3 has inbuilt Array, Object, Dictionary, Vector data structures. This page provides a brilliant overview. In addition there is a LinkedList implementation though I have not found a place to use it yet.

The Vector data structure is interesting because it is the only typed container. It was added to improve performance of high throughput game code using internal prediction (as each data item has fixed size).

var newVec:Vector.<int> = new Vector.<int>;
newVec.push(1);

Note the strange dot syntax, unlike Java or C++. Expect more of these generics in later versions of ActionScript.

The Dictionary object has many useful features. The operator in is useful for determining whether a key is in an associative array. A useful AS3 feature allows direct iteration over both keys and values:

for (var key:Object in dict) { }
for each (var value:Object in dict) { }

Arrays do not have a copy method. The best solution I have found is to use concat to create the new array.

Data structures have functional methods like Array.filter. Unfortunately the callback function is verbose.

function callback(item:*, index:int, array:Array):Boolean;

AS3 Data Structures For Game Developers is promising for data intensive applications.

Design patterns

Classes have strange behaviours. For instance you have to be careful how you call super. They have an additional internal modifier the common private/protected/public/static modifiers. This specifies that a property is visible within the same package (see more).

Singletons are often useful in AS3. Especially when performing multiple calls to a web service. Unfortunately private constructors are not supported by Adobe to preserve backwards compatibility with the ECMA specification.

Many people diagree with Singletons. See Why Singletons are Evil for a powerful argument against their use. I think they have a place in rapid web development, at the expense of component rigidity.

Text handling

Font embedding is required by most Flash application designs. It is not intuitive in Flash Builder 4. The first comment about this article works well. It details:

  1. Start a new flex app
  2. Go to design view
  3. Open the “Appearance” tab on the right
  4. In the font drop down list, you can choose browse to find your font files.

Word wrapping in Flex 4 is achieved by setting a width and changing the line break style:

<s:Label width="200" lineBreak="toFit" />

Scrolling

Scrolling is common in a large amount of applications that load data dynamically. Joeflash’s Enigmacopaedia has an excellent explanation of how to mask a group with a rounded rectangle. You can bind horizontalScrollPosition to the scrollbar value. Then when the scrollbar is modified the visible area of the scrollable group reflects the value change without additional code.

Top source for learning is the Adobe documentation on HSlider.

Skinning

Most media projects require complete skinning. Learning how to skin a scrollbar takes you most of the way towards creating a variety of custom skinned components.

Many components can be skinned simply by changing the source image of an internal bitmap. Skinning in Flash using XML Spark components reduces release size. Layering inbuilt shapes with strokes, fills and visual effects can easy emulate Photoshop designs of interface elements.

Mouse handling

Any descendant of the Sprite class (most UI components) has a buttonMode MXML attribute that shows the pointer cursor when the mouse hovers over the element. By default transparent sections in the element are ignored by the mouse. This is intuitive but can annoy users when half the pixels are not clickable. This mouseEnabledWhereTransparent property toggles this behaviour.

Thanks for reading, please add your comments.

Decentralised XML storage

Over the past couple of years I have been experimenting with an XML storage system for displaying articles. I first wrote about during my 2008 homepage refresh. The last couple of days have seen a major overhaul, converting from a centralised XML database to dispersed XML files that accompany each entry. The article directory is parsed and these XML files are collated and serialized by PHP.

Having a decentralised storage mechanism allows greater integration with the filesystem. It removes the need to update and overwrite the XML database after every change. Now a new article can be uploaded to a directory using FTP and automatically deployed on a cache refresh.

Example XML info file

The XML format allows content to be mapped to different output types. This webpage is delivered as XHTML so the convertor identifies PHP Markdown as a class library to achieve the mapping.

<?xml version="1.0" encoding="UTF-8"?>
<article>
    <title>Decentralised XML storage</title>
    <created>Sun, 15 Aug 2010 00:07:05 +0100</created>
    <modified>Sun, 15 Aug 2010 00:07:05 +0100</modified>
    <content format="markdown" src="decentralisedxmlstorage.mdml"/>
    <category>Writing-Development-Flux, Flux</category>
</article>

How to detect changes

In many computer systems a dirty bit is set to signify that modifications have taken place and the cache line should be refreshed. Deleting the cache is a simple solution, forcing the directories to be indexed. This is an appropriate solution for up to 1000 articles. Beyond these scales a more efficient solution would detect filesystem modification times. Is it sensible to trust system time? I would rather not go there.

Major modifications

The decentralisation is a major step towards a class library that can be used by other developers to deliver high quality content in less time. A single file management interface is the final stage before release.

Thanks for reading, please add your comments.

Creative X-Fi issues on Windows 7

X-Fi Platinum Fatal1ty Champion contents.

An occasional pop in the midst of silence, a little crackle while watching a movie — these are features that I did not order with my X-Fi Platinum Fatal1ty Champion sound card back in 2008. Creative drivers are appalling and the company is starting to gain notoriety on the internet as just another large company who does not care about its customers. They consistently ignore plees to improve their drivers and blocks enthusiasts from creating improved versions. The driver is broken, please fix it.

Daniel_K, a user on the Creative Forum, is a lone philanthropist who edits the drivers to enable hardware features that Creative Labs that have intentionally crippled. I am about to install Daniel’s support pack and his updated driver from August (after observing the multitude of positive reviews):

  1. SB X-Fi Series Support Pack 2.0 (2009-05-15)
  2. SB X-Fi Series driver 2.20.0001 - Forte v1.1 (2009-08-06)

Creative do not like Daniel providing its customers with working drivers. Wired investigated and questioned Creative directly:

O’Shaughnessy admits that Creative Labs intentionally crippled its Vista drivers as a business strategy.

My next sound card will not be Creative. The Asus Xonar D2 Sound Card is a viable alternative at a much lower price (half of my Champion Edition) with brilliant reviews all over the internet. Next time I purchase hardware I will ensure customers are satisfied.

Thanks for reading, please add your comments.

Journal feed generation, RSS and Atom

For the past few hours I have been trying to integrate a feed generation library into my new blog system. After a couple of minutes searching on Google I came across Anis uddin Ahmad’s PHP Universal Feed Generator. This feed generator can create Atom, RSS 1.0 and RSS 2.0 feeds.

There were a few mistakes in his program: to begin with, escaping data in the XML output using the PHP function htmlentities is incorrect because it will generate entities that are not part of the XML standard. Instead you should allow native UTF-8 characters to remain in the XML document and only escape the small subset of characters that XML uses. I fixed other niggles, including making a method of FeedWriter public static.

I want to write my own feed generator and release it to the world. I wrote the feed generator for Mind & Soul when I was working for Premier Media Group. With some of the knowledge gained from my first year computer science course I could do a far better job. I will now take any excuse to try out my new skills!

Converting to absolute URLs

Many of the files on my server reference other files using an absolute URL syntax such as /journal/view/test. This will break down if the files are transported to another server if the path changes. The path should either be relative (would require lots of processing) or be absolute and include the domain part.

Webmail clients can interpret feed links and images, allowing users to travel to external pages or view images directly in the client. This means that I will definitely have to change the URL system in Base (my CMS) and the implementation of FluxLinkage. The latter is an interface to connect the journal system with other classes, in this case my CMS, and to adapt to their style of page linking.

Speech recognition

Dragon NaturallySpeaking seems to have problems interpreting my speech when writing CompSci blog entries… However, it is an awesome piece of software and it gives me an excuse for making more grammar errors.

Thanks for reading, please add your comments.

Strength level calculator — new Internet utility

Strength training has been one of my predominant passions for the past few months. It has always been difficult to track changes and ensure that I have been making real progress; because of this I have created a new Internet utility to measure strength levels. It is unfair to judge strength on the magnitude of weight lifted alone, or even as a ratio to bodyweight because people are built in different ways.

The strength ability calculator processes data on experience against bodyweight and weight lifted and calculates an experience level. These levels generally range from untrained (1) to elite (5). Of course the top professionals and world record holders exceed this range and some people may not reach untrained.

Testing some of the famous powerlifters, Konstantin Konstantinovs receives a healthy rating 8.49 for his massive 430 kg deadlift at 125 kg body mass; this is far better than Andy Bolton’s record breaking 460 kg deadlift at 160 kg bodyweight (rated at 7.97). One idea for the future is using my new rating system to create tables of powerlifters irrespective of bodyweight to find out who is truly the strongest person ever to have lived.

Thanks for reading, please add your comments.

More articles on the next page or go back