Posts Tagged ‘AS3’
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, 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 »
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 »
Saturday, October 11th, 2008
There is a fantastic technique for getting graphics drawn in Flash into Flex by means of classes compiled into a swc. It’s a really nice little method and if you wanna learn about it Ultraviolet Design have a great post about it here. I’m pointing you towards their post as this post is not going to be about that. Instead it’s going to be about what happens when that technique - which usually works fine - goes unexpectedly and bafflingly wrong.
(more…)
Tags: ActionScript3, AS3, error, FlashBrighton, swc
Posted in AS3, Bugs, Flash, Flex | 2 Comments »
Tuesday, August 26th, 2008
// this:
var id:int = 0;
var name:String = id.toString();
// as opposed to this:
var id:int = 0;
var name:String = "name_" + id.toString();
// and ESPECIALLY this:
var id:int = 0;
var name:String = "obj_" + "name_" + id.toString();
Conclusion: each additional concatenation adds roughly an additional 20% to processing time
Twenty percent is a lot if you’ve gotta run through a long loop and assign properties to a whole bunch of properties. Anywhere where you can avoid concatenation you should. Storing values indexically with integers seems by far the best way to go with this, whether you are storing your data in Arrays, Dictionaries, Objects or your own bespoke class. Concatenation is going to drag you back wherever you use it.
Tags: ActionScript3, AS3, FlashBrighton, Optimisation
Posted in AS3, Code, Optimisation | 1 Comment »
Thursday, August 7th, 2008
// this:
public var id:int;
// as opposed to this:
private var _id:int;
public function get id ():int
{
return _id;
}
public function set id (id:int):void
{
_id = id;
}
Conclusion: Public properties are roughly 20% faster than private vars with getters & setters
If you don’t need to run any code on a class property why bother writing a getter and a setter for it? It’ll take longer to type (FDT users aside), make your code fatty and run slower. Tell me the advantage in all that. Instead, why not just use a public variable with the caveat that if you need to turn it into a private variable with a getter and a setter later you can?
Tags: ActionScript3, AS3, FlashBrighton, Optimisation
Posted in AS3, Code, Optimisation | 1 Comment »
Friday, February 8th, 2008
That, in a nutshell is your three-step guide to instance class-creation happiness in AS3. Let me explain:
public function SomeClass ( name:String )
{
_name = name;
_init();
}
private function _init ():void
{
// your initialisation code here...
reset();
}
public function reset ():void
{
// your reset code here...
}
This public - private - public approach to initialising your AS3 objects will make you life SO much easier. Let me tell you why:
(more…)
Tags: ActionScript3, AS3, FlashBrighton
Posted in AS3, Code, OOP | 2 Comments »