Archive for the ‘Code’ Category
Tuesday, January 24th, 2012
ONE of the reasons this might happen is because of the following:
public static function compareStrings ( firstString:String, secondString:String ):String
{
firstString:String = tidySpace( firstString );
...
}
You see that firstString:String = etc there? That’s the fella. DON’T EVER strongly type your vars more than once, unless you wanna lose an hour of dev like I have this morning.
Posted in AS3, Bugs, Code, Flash | No Comments »
Thursday, August 12th, 2010

[click the image to see a larger version]
This diagram outlines an XML load procedure. Complicated, no? That’s because it’s for an AIR app, and therefore has to cope with situations other Flash & Flex apps don’t. I’m showing it to make the case for planning AIR apps in advance as much as possible.
(more…)
Tags: AIR, Flash, Flex
Posted in AIR, AS3, Code, Flash, Flex, Theory | 1 Comment »
Sunday, December 20th, 2009
Robotlegs is an AS3 dependency injection micro-framework.
Signals is a new approach for AS3 events, inspired by C# events and signals/slots in Qt.
Put them together and you’ve got an elegant, simple & completely decoupled solution to the problem of Flex & AIR development.
I’ve thrown together a really quick example (which you can download below) based upon a couple of things I’ve seen recently; firstly Richard Lord’s framework comparison talk at FlashBrighton a couple of weeks ago, and secondly, Owen Bennett’s blend of RobotLegs and Signals he showed me last week. Seeing what Owen had put together inspired me to have a go myself. I wondered whether it was possible to create a RobotLegs/Signals hybrid that was even more decoupled than the system Owen was working on. So I created a short (less then 100 lines) class called ‘SignalBox’, named after a similarly named class in Owen’s system.
(more…)
Tags: as3signals, RobotLegs, Signals
Posted in AS3, Code, Default, Flex, MXML, OOP, RobotLegs, Signals, Theory | 3 Comments »
Sunday, January 25th, 2009
I use FlexBuilder. I used to use FDT but the code-completion, hover-over links and - most importantly - ability to compile from MXML that FlexBuilder offers eventually tempted me away. Still, there’s one thing about FDT I miss: it wrote A LOT of code for me. Nothing complicated, stuff like getters & setters that are tedious and time consuming. It was great that FDT could take that off my hands.
These days, with FlexBuilder, I don’t have that any longer. Which isn’t great but I’ve managed to concoct a workaround using ‘Snippets’, comments and ‘dormant’ variables, which has sped things up for me and which could do the same for you.
Let me explain…
(more…)
Tags: ActionScript3, AS3, comments, snippets, variables
Posted in AS3, Code, Flex, Optimisation, Tutorial | No Comments »
Thursday, January 8th, 2009
A subject particularly far away from my heart; I have always loathed font embedding, because there are so many ways of doing it and they don’t always work and when they do it feels like some weird voodoo that could inexplicably disappear at any moment is part of it! Which is why I’m very grateful to have recently been shown a method of achieving this by Unwrong’s marvellous Flash Developer Jonathon Pace. Jon’s method is simple, relatively error-free and seems to work for all font types - the ones I’ve tried thus far, at least - which was always the biggest bugbear for me; it sometimes felt like you had to know a different embedding method for each different font type!
So, using Jon’s method what you have to do is:
- Create a fonts swc;
- Ensure your compiler includes every font in your swc; and
- That’s it! Use your embedded fonts
(more…)
Tags: ActionScript3, AS3, embed fonts, FlexBuilder
Posted in AS3, Code, Flex, Tutorial | 5 Comments »
Wednesday, December 17th, 2008
Over the summer of 2008 I decorated my bathroom. I knew from doing my kitchen the year before that the most painstaking and time-consuming part of the job would be tiling and I wondered if there was anyway it could be made less so?
I had just come back from BarCampBrighton, where I was inspired by Ollie Glass‘ workshop on writing genetic algorithms; something that turned out to be really simple. So I sat down, chucked some code together and produced this Tile Designer swf, built on a genetic algorithm:
Tags: Flash, genetic algorithm
Posted in AS3, BarCampBrighton2, Code, Flash | 2 Comments »
Wednesday, November 19th, 2008
This turns out to be outrageously simple. If you wanna create a grayscale somewhere between pure black and pure white all you need is this could-not-be-simpler equation:
var num:int = 1; // any int from 0 to 255
var grayscale:int = num * 65793;
All you need to ensure is that the value of ‘num’ is an integer from 0 (for pure black) to 255 (for pure white) and that’s it!
Tags: AS3, grayscale, greyscale, hex, hexidecimal
Posted in AS3, Code, Flash, Tutorial | 3 Comments »
Friday, November 7th, 2008
Sitting at the back of Grant Skinner’s session at ‘Flash on the Beach’ a few weeks ago i got my cellular automata classes out and did another visualisation with them. It’s really nice that they’re so easy to use, I can bash something like this out with in just a couple of hours. Again, just click the wee arrow to get going:
OK, not the most astonishing work, it would really be nice to push the envelope a bit further with it. Putting autonomous objects in a controlled environment is obviously going to be a rich vein for software, visualisations, experiments and games for the foreseeable future and I’m currently wondering quite how we can use that stuff in interesting new ways.
Tags: cellular automata, Flash, FlashBrighton, Generative, SussexDigital
Posted in AS3, Code, Flash, Generative | No Comments »
Monday, November 3rd, 2008
One of the projects I worked upon over the summer was destined for the South-American market and therefore needed to display in both Spanish and Portuguese. It was a microsite built in Flex and needed the capacity to alternate between these two languages at any given time. From the user’s perspective, a single button click should be sufficient to translate the entire site’s text from one language to another instantly. Looking around the web I couldn’t find any answers so I sat down and worked out a solution myself.
Here’s a sample app using English and my second language Swedish:
(more…)
Tags: ActionScript3, AS3, Flex, localised, localized, multi-language, multilanguage
Posted in AS3, Bugs, Code, Events, Flash, FlashBrighton, Flex, MXML, News, OOP, Optimisation, Theory, Tutorial | 8 Comments »
Sunday, October 12th, 2008
I love the tools I work with but if I’m being honest, some things just don’t measure up. CSS in Flex for instance: it doesn’t do half the things a genuine CSS implementation should do. Thanks go to Tom Kennett for bringing to our attention this great blogpost about just how far short of the mark Flex’s CSS support falls.
One of the most irritating aspects is the fact that the ‘width’, ‘height’, ‘percentWidth’ and percentHeight’ properties of UIComponent - which is the base class for all visual components - are exactly that: properties, not styles. That means they can’t go into the CSS, they have to be added to the mxml tags themselves:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:VBox width="100%">
<mx:HBox id="header" width="100%" height="80" />
<mx:HBox id="content" width="100%" height="100%" />
<mx:HBox id="footer" width="100%" height="50" />
</mx:VBox>
</mx:Application>
Even in an unrealistically small file like this, the ‘width’ and ‘height’ attributes make it difficult to read. When working with actual, lengthy .mxml files, a bit of simple editing can become like hacking through the jungle. I’m not really into that so I thought I’d sit down today and see if I could concoct a workaround that would allow me to put the ‘width’ and ‘height’ declarations in the CSS instead.
(more…)
Tags: ActionScript3, AS3, CSS, FlashBrighton, Flex, height, PureMVC, width
Posted in AS3, Code, Flex, OOP, PureMVC, Tutorial | 1 Comment »