Ruben’s blog

Ruben Swieringa on Actionscript and a whole lot of other stuff..

Interactive mindmap

As promotional material for today's view day at my course I made an interactive mindmap which was beamed onto one of the walls of the classroom of the 'Next Web' minor.

I got some really positive responses so I decided to post it here, click the screenshot below to check it out (navigate by clicking an element). Also feel free to check out the source-code.

Credits also go to Mark Shepherd, I used his very very awesome and super-easy to use SpringGraph component. I also used Maikel Sibbald his Sticky ToolTip for the description of every element, so thanks man.

On top of that I used the Flex component kit for Flash as to be able to create the visual effects of elements in Flash.

Open/closed design principle

A while ago a friend and I were having a discussion about the use the private and protected access control attributes in AS3. While I stated that you should always try to write your code as open as possible as to make it flexible, he said that you should always make your code closed unless it was explicitely designed to be not so.

I think the open/closed design principle makes a good compromise: "open for extension, closed for modification".
What it means is that code should be written so that other programmers can easily add functionality by subclassing your classes (extension), while at the same time 'private' stuff like errors will have to be fixed within the original class (modification).

Using DistortImage with dynamically loaded images

About a week ago someone asked me through the comments-section of a previous post if it was possible to use the DistortImage class with non-embedded (runtime-loaded) images.

Here's an example:
DistortImage dynamic loading demo
DistortImage dynamic loading demo source

NOTE: I wrote that the code added to the mxml-file in a bit of a rush, it is by no means an example of best practices or what properly written code should look like. Forgive me ;)

In the source-code (dynamic.mxml) I put some extra comments in an attempt to clarify where this code differs from that in the mxml-file of the original demo.

As you can see most of the new lines of code are spent on actually loading the external bitmap, only two of the last lines of Actionscript (where it says "fetch BitmapData") are essential to the preparation of the bitmap-data.

Beyond Boundaries Amsterdam

Last tuesday a bunch of other students from school and I took a traintrip to Amsterdam to see Daniel Dura, Sakri Rosenstrom and Serge Jespers talk at Beyond Boundaries Amsterdam.
At 8 in the morning I met up with Arno at the trainstation in Leeuwarden, just in time to eventually be really late for the first lecture by Sakri. So here's what the day looked like:

Read the rest of this entry »

Ambiguous reference bug for namespaces in Flex

Before coming up with a solution for binding read-only accessors a few months ago, I had already tried out various alternatives, among which the following (which was later also pointed out by others through the comments):

[Bindable]
// public getter:
public function get someProperty ():String {
  return this._someProperty;
}
// protected setter:
protected function set someProperty (value:String):void {
  this._someProperty = value;
}

However, the problem here was that Flex throws an error saying "1000: Ambiguous reference to someProperty" whenever you try to use the setter.

After reading a post by Adam Flater I decided to start looking through the documentation and found out that this is in fact a known compiler bug:

174646: If a class contains accessor functions with different access control namespace attributes, (for example, aprotected setter and a public getter) using one of them causes a compile-time-error, for example,Compiler-Error 1000: Ambiguous reference to myVar
The workaround is to rename your getter or setter function to avoid the mismatch.
Common Flex 2 compiler errors and known issues

This bug doesn't seem to have been fixed in any of the Flex 2 hotfixes, and neither in the Flex 3 Beta (thanks to Wietse for testing). Let's hope the folks over at Adobe are going to do something about it..