Currently Reading

Image of Derivatives Demystified: A Step-by-Step Guide to Forwards, Futures, Swaps and Options (The Wiley Finance Series)

Image of Working Effectively with Legacy Code (Robert C Martin)

Image of Coders at Work: Reflections on the Craft of Programming

Image of Succeeding with Agile: Software Development Using Scrum (Addison-Wesley Signature)

Image of iPhone UK: The Missing Manual

Image of My Shit Life So Far

Recently Read

Image of iPhone Advanced Projects (Books for Professionals by Professionals)

Image of Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)

Image of UML 2 for Dummies

Image of Test Driven Development (The Addison-Wesley Signature Series)

Image of Cloud Atlas

Image of Advanced Actionscript 3 with Design Patterns

Image of Refactoring: Improving the Design of Existing Code (Object Technology Series)

Image of ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Adobe Developer Library)

Image of The Secrets of Consulting: A Guide to Giving and Getting Advice Successfully

Image of Beginning iPhone 3 Development: Exploring the iPhone SDK


July 10, 2010

Converting MX Component to Spark Component ( Part 2 – a )

Filed under: ActionScript, Components, Flex — Anthony @ 2:13 pm

In the previous post we began building our custom Spark colorPicker by creating the preview class and it's corresponding default skin.
In this post we will begin by creating a KeyboardManager class that will allow us to calculate the new index in the dataProvider after a Up/Down/Left/Right keyboard input.

This class can become quite complicated because we want the following behaviour from our keyboard manager.
The selected index should be able to move up past the top of the dataProvider and move to the bottom row and vice versa, in addition we should be able to go off the left hand side of the columns and appear on the right hand side and vice versa.

For example if the dataProvider has 25 items and each row contains 5 columns.

Up / Down Examples.
If we are at column 1 row 1 ( box 1 ) and we press up we should go to column 1 row 5( box 2 ) and then for every key press we should move up the column until we hit the row 1 column 1 index again. However if we press down then we should go to column 1 row 2 and so forth until we hit column 1 row 5 ( box 2 ). Then when we press down again we should move to the top of the column again row 1 column 1 ( box 1 ) and this should be the case for each column no matter how many rows it has.

Box 1          Box 2
Box oneBox two

(more...)

June 10, 2010

Converting a MX component to a Spark Component.

Filed under: ActionScript, Components, Flex, Test Driven Design — Anthony @ 12:27 am

In this brief set of posts I wanted to document how to convert a simple MX component over to a Spark component. I have chosen to convert the MX ColorPicker because it is one of the components that Adobe hasn't moved over to the Spark framework yet as well as being the component that I used to learn the Flex3 Framework. You can see the outcome and view the source of that in my previous posts from a couple of years ago here and here

Below you can see the three components.

The Spark component does all the stuff the old MX one does like keyboard movement, selectedIndex, selectedColor, colorLabel, etc.. In addition I also added the ability to set/get the selectedItem and dispatching indexChange events.

To begin with lets look at what the current color picker does. (more...)

May 6, 2010

Custom FlashBuilder Component Views

Filed under: ActionScript, Components, Flex — Anthony @ 12:34 am

I recently discovered that you can create custom components that can appear under your own company/personal folder inside Flash/Flexbuilder design view. Normally any custom component you create will appear under the Custom folder in the Components View and well thats not very good for branding now is it. In addition you also get an actual size representation of your component in Design view rather than just an empty box outline. For example the first image is the default and the second the custom. (more...)

October 16, 2009

Binary Clock

Filed under: ActionScript, Personal, experiments — Anthony @ 11:56 pm

I have been looking into bits, bytes and bit shifting a lot recently so I thought I would quickly make a small binary clock to help burn it into my mind. In addition it also gave me the chance to experiment with the spark skinning. Below is the result. Not pretty I know but thats what the skinning is for.

[kml_flashembed publishmethod="static" fversion="10.0.0" movie="http://www.betadesigns.co.uk/Examples/BinaryClock/TestProject.swf" width="169" height="92" targetclass="flashmovie"]

Get Adobe Flash player

Full source

September 28, 2009

Forcing the Browser to crash using ActionScript

Filed under: ActionScript, Flex — Anthony @ 11:59 pm

I just discovered this little trick, I'm not sure how useful it is but it works.

Simply create a class that throws an error in the constructor. This will cause the browser to crash and close.

 
 
package
{
   public class BrowserCrasher
   {
      public function BrowserCrasher( )
      {
         throw new Error( 'goodbye browser' );
      }
   }
}
 

Enums and static initializers in AS3

Filed under: ActionScript, OOP — Anthony @ 10:24 pm

I just came across the idea of static initializers in Java and was wondering if they are available in ActionScript as well.

I found a couple posts on the subject.

post 1

post 2

July 16, 2009

Layout Organizers

Filed under: 3D, ActionScript, Uncategorized — Anthony @ 4:12 pm

I recently stumbled across this awesome project by somerandomdude and just wanted to give it some exposure as it is open source and even in 3D

July 8, 2009

Mixin’s in ActionScript 3

Filed under: ActionScript, Flex — Anthony @ 11:48 pm

I was strolling through the UIComponent source code earlier today when i cam across this line of code.

 
 //--------------------------------------------------------------------------
    //
    //  Class mixins
    //
    //--------------------------------------------------------------------------
 
    /**
     *  @private
     *  Placeholder for mixin by UIComponentAccImpl.
     */
mx_internal static var createAccessibilityImplementation:Function;
 

I wasn't entirely sure what a mixin was but after reading up on wikipedia I realized they are exactly what they sound like basically just a mix of code bases. There is a really good post over on the yahoo flash blog about accessibility and the way in which Flex uses the

 
[AccessibilityClass(implementation="mx.accessibility.UIComponentAccImpl")]
 

meta data to mixin the Accessibility code into the UIComponent implementation.

March 18, 2009

Unable to Catch IOErrorEvent’s when Loading a ByteArray into an Image

Filed under: ActionScript, Bug Fixes, Flex — Anthony @ 1:07 pm

I was trying to load a byteArray into an image control today and would randomly get an Unhandled IOErrorEvent message. Now this shouldn't really happen as the image control uses a default broken image icon to display when there are any loading problems. Well after trying to catch the error unsuccessfully I wanted to know what was going on.
So i went digging and i found in the base class of image, SWFLoader line 1497 the following (more...)

March 12, 2009

Flex Cookbook Recipe 5.8 Allow Certain items in a list to be selectable, Doesn’t quite work correctly

Filed under: ActionScript, Bug Fixes, Flex — Anthony @ 11:38 am

Ok I needed to disable Heading elements inside a List Component in Flex, and i was being too lazy to work it out for myself so i picked up the Flex cookbook Adobe had been kind enough to send me and yes... It was there. Now the Mouse removal was straight forward and worked like a charm. But the keyboard events were a different story. The code didn't work for several reasons.
1. Key directions were not being assigned.
2. When a disabled item was at either the top or the bottom of the list it would stop you being able to continue down / up the list.
To fix this i added the following code. (more...)