AS Frameworks

Recently I’ve been looking into different frameworks, just to get some experience with other interesting frameworks out there. I’ve compiled a list of some of the frameworks I’ve found. I’m sure I’ve missed a couple of other good ones, if you know of one, please let me know. 🙂

Gaia
A framework package as a Flash component. Handy for designers, but it kinda made me shrug… Though reading through the docs a couple of interesting features showed through, like the generation of the navigation through the context menu.
Link: http://www.gaiaflashframework.com/index.php

Cairngorm
Used this framework / micro architecture a lot already. Nice Event-Command pairs as well as delegates for calling all (web)services.
Link: http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm

PureMVC
I’ve been working with a PureMVC project lately and looked at it before, quite similar in some ways to Cairngorm, just different names. 😉
A nice resource for pureMVC: http://puremvc.tv/
Link: http://puremvc.org/

Swiz

Swiz is a framework for Adobe Flex that aims to bring complete simplicity to RIA development. Swiz provides Inversion of Control, event handing, and simple life cycle for asynchronous remote methods.

Link: http://code.google.com/p/swizframework/

Dawn

Dawn is a lightweight framework for ActionScript inspired by Google Guice. In addition to Dependency Injection, it provides type safe notifications and helps you to build apps which are loosely coupled, easily unit tested, and less error-prone.

Link: http://wiki.github.com/sammyt/dawn

Mate

Mate is a tag-based, event-driven Flex framework.

Mate framework has been created to make it easy to handle the events your Flex application creates. Mate allows you to define who is handling those events, whether data needs to be retrieved from the server, or other events need to be triggered.

In addition, Mate provides a mechanism for dependency injection to make it easy for the different parts of your application to get the data and objects they need.

Link: http://mate.asfusion.com/

I think I’m going to give Dawn a try soon enough, of all the above it looks the most interesting to me.

Flash on the Beach 09 – Play with Vectors

Warning: Illegal string offset 'language' in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 510 Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 513 Warning: Illegal string offset 'language' in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 510 Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 513 Warning: Illegal string offset 'language' in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 510 Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 513

This year I was only able to go to Flash on the Beach on the very last day. Never the less it was once again a really awesome experience and I learned a lot and got a lot of inspiration as well. I’ll try and post my notes from all the talks I’ve seen, but it might take a while…

23-09-2009 9.00 Koen de Wieggheleire – Play with Vectors
Koen did a very in depth talk about the Vector class in AS3.

The Vector class is a dence array which means that it can’t have any gaps, so something like the below would throw an error:

  1. myVector[0] = 'bla'; // See how we're skipping positions 1 and 2?
  2. myVector[3] = 'something else';

You can you an array as a ‘data provider’ to populate a Vector:

  1. myVector = Vector.<String>(myArray);

Using the Vector class will give you a performance boost of about 40 to 60%.
Unfortunately you can’t directly bind to a Vector in Flex, you can however write a wrapper class and bind to that. 😉

How to use in 3D

The Matrix3D class is somewhat complex to understand, but the image below should clarify it a bit

You can use myDisplayObject.transform.matrix3D to retrieve a DO’s Matrix3D or assign a new matrix3D to it. There are also build in methods to user rather than creating a new Matrix3D all the time, see http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Matrix3D.html

Nice thing I only found out now about matrixes: You can skew objects with it! Rock on!!! \m/

How to use with 2D

Pretty much the entire graphics API in Flash relies on Vectors. The drawPath() method below (which is pretty much the core of drawing vector shapes) takes two Vectors (the Vector data type) as arguments.

  1. graphics.drawPath(commands, data)
  • the commands argument is a Vector containing GraphicPathCommands
  • the data argument is a Vector containing x and y pairs that determine the path to draw.

The new Illustrator can export to FXG and you can actually import this FXG data on the fly in Flash, parse it and draw the exact same.

Some notes on UVT (texture) mapping:

  • U matches up with the x location
  • V matches up with the y location
  • T determines the focal length

The right value for T can be calculated with the following formula: T = focalLength / (focalLength + z)

Useful links:

Colors and bitwise operators

Warning: Illegal string offset 'language' in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 510 Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/ansuz.nl/subdomains/blog/httpdocs/wp-content/plugins/igsyntax-hiliter/classes/frontend.php on line 513

I found this very interesting post called “Hex colors & bitwise operators” on www.tracestatement.com a while back and I’ve been meaning to blog about it.

  1. // From hex value to r,g,b values
  2. var hex:uint = 0xFF8811;
  3. var r:uint = rgb >> 16;
  4. var g:uint = rgb >> 8 & 0xFF;
  5. var b:uint = rgb & 0xFF;
  6.  
  7. //From r,g,b values to hex value
  8. hex = (r << 16) | (g << 8) | b;

This tiny bit of code allows you to rapidly subtract the Red, Green and Blue values from a hexadecimal colour code. Once you have the R, G, B bits you can then manipulate them and once done convert them back to a single Hex value.

An important thing to remember is bitmasking, this can be used to switch a set of bits either on or off.

Flash Camp London

13.30 – 14.00 Keynote
Serge Jespers (Adobe)

14.00 – 14.30 Work / Play
Seb Lee-Delisle (Plugin Media / PV3D)

15.45 – 16.30 Scripting with AS3
Mike Chambers (Adobe)

16.30 – 17.00 Spore Microsite
Richard Dean (Creative Lead – Lightmaker)

17.00 – 17.30 Custom Chrome in AIR
James Whittaker (Front-end technical architect / Adobe Community Expert)

18.15 – 19.00 Flash CS4
Lee Brimlow (Adobe)

19.00 – 19.45 Flex workflows in CS4
Serge Jespers (Adobe)

Project Capuchin

Rocks! It’s very interesting to work with. Hopefully soon I can post about a first application.

Sony Ericsson’s Project Capuchin technology is a Javaâ„¢ ME API that defines a bridge between the Java ME and Adobe® Flash Liteâ„¢ programming environments.

In other words: You can have a Flash front-end talking to a Java back-end on a mobile phone. Now how cool is that?! 🙂

Link: Project Capuchin Docs and Tools

FLVPlayback skin

I had the immense pleasure *ahem* of making a skin for the FLVPlayback component this week. I learned two valuable lessons from this:

  1. Guide or Layer! When adding buttons don’t forget to change it’s layer from a guide back to a ‘normal’ layer.
  2. Instance names! If you change a couple of the default buttons and are messing around with different MCs, don’t forget to give them the right instance name(s).

I spent quite a lot of time figuring out why things didn’t work as expected, mostly due to the 2 points mentioned above.

TBC…

Deserializing data

When deserializing data, do it at the very first time you can and continue to use the deserialized data throughout your application. This will save you a lot of aggravation later on.

Take deserializing XML into (Value)Object(s), when you want to change the objects later on, say add, remove, alter properties you can easily do so, it’s quite a bit harder to insert a node or attribute into the (serialized) XML.

Links:
(De)Serialization