Archive for the ‘ActionScript 3.0’ Category

Some things are null on Win, but not on Mac

Thursday, July 15th, 2010
Actionscript:
  1. var myArray:Array = new Array(new SomeObject(), new SomeObject(), new SomeObject());
  2. // true on Win, false on Mac
  3. trace(myArray[3] == null);

Such fun those little differences in the Flash Player! :)

De MonsterDebugger

Thursday, March 11th, 2010

I'm always looking for a nice debugger to use on the fly, the "De MonsterDebugger" looks really nice.

De MonsterDebugger is an open source debugger for Adobe Flash, Flex and AIR. De MonsterDebugger is made in Flex and AIR by design studio De Monsters.

One of the nicest features in my opinion is the live editing of properties, very handy when fiddling to position elements correctly.

Links:

Phidgets / Arduino

Wednesday, January 20th, 2010

I'd love to have some time to mess around with a Phidgets or Arduino board, it looks like a lot of fun! Using Flash to control something analog/physical! :D

Flex IRC Client

Thursday, January 14th, 2010

Just came across this when browsing around a bit. This Flex IRC client is a port of the Java-based PircBot.

Flex IRC Client aims to be a Flex / Flash based IRC Client. Currently most browser-based chat solutions are either proprietary or applets. Flex IRC Client wants to bring the power of IRC to the majority of the Internet-users without requiring a download or an install.

I know this client is still under development, but it could really do with a window showing some progress when connecting to a server. Also, a proxy of sorts would be nice since I get a lot of Security Errors when trying to connect to a server: "SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://ansuz.nl/toys/irc/FlexIRCClient.swf cannot load data from irc.efnet.nl:6667."", probably due to no cross-domain policies being set on the IRC servers. Connecting works when running this locally ;)

Links

Glaze: game and physics engine

Tuesday, December 15th, 2009

Just stumbled upon this one. :)

A game and physics engine for Flash including:

  • Rigid Body Dynamics
  • Scene management
  • Line of sight
  • User Input
  • Scrolling
  • AI

Project home: http://code.google.com/p/glaze/
Example: http://home.planet.nl/~borst595/glaze.html
Blog: http://yaa-blog.blogspot.com/

AS Frameworks

Tuesday, December 15th, 2009

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.

AS3 Version Injection + Flex PMD + TDSI = Rock ‘n Roll! \m/

Wednesday, October 21st, 2009

AS3 Version Injection

Ever been annoyed by Project Managers telling you that a bug you fixed is still in the latest release you did and after some investigation find out that they forgot to clear their cache? Well, fear not! An AS3 Version Injection script is here! :P
I've created a simple AS3 class called Version that will add a time stamp to the context menu. All you need to do is instantiate the Version class once and pass it a reference to you Document Class. On top of the AS I've written a little Ant script that will take a template of the Version class, insert the current date and time and write out the Version class. This way you can just make it part of your Ant build and don't need to worry about manually updating the version number. Also, now you'll have a way of quickly identifying what version somebody is looking at. :)

Flex PMD

This is great for auditing your own code as well as other people's code. I've written a small Ant task that can be ran as part of a build that will run your project through Flex PMD and create a PMD file for you. The PMD file will have a time stamp suffix so you don't overwrite your old file and you can compare issues. To use this Ant script make sure you've downloaded PMD for Ant.

TDSI

Another piece of very useful technology. Up to 20% performance increase just by passing your SWF through it. I downloaded the Apparat source (where TDSI is part of) from Google Code and compiled it. Built another little Ant script to use TDSI with Ant. Just specify the input and the output file and you're done!

Bringing it all together

All the above Ant scripts are saved in a separate file. This way I can import whatever piece I want in my build script, example:

XML:
  1. <import file="as3_version.xml" />

TIP: Place the import after you have defined your properties in the build script, this way the imported scripts can use the properties set in the build script.

Links

Flex PMD

Tuesday, October 13th, 2009

Nice! A Flex (automated) auditing tool! :)

FlexPMD is a tool that helps to improve code quality by auditing any AS3/Flex source directory and detecting common bad practices

Would be interesting to start using this.

Gotcha:
The PMD Violations Viewer only accepts files that are named "pmd.xml", all other files will not be recognized. I run an Ant task to rename the generated pmd.xml to pmd_[insert timestamp here].xml. When I tried uploading the renamed file the PMD Violations Viewer wouldn't accept it. :(

Links:

Flash CS5 - Apps for iPhone

Tuesday, October 6th, 2009

This is awesome! With CS5 you'll be able to produce iPhone application using AS3, that's insane! :D

Links:

Flash on the Beach 09 - Play with Vectors

Thursday, September 24th, 2009

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:

Actionscript:
  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:

Actionscript:
  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.

Actionscript:
  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: