Archive | April, 2019

ArgumentError: Error #2004: One of the parameters is invalid

03 Dec08

Just figured that Flex will start throwing this error if you don’t set the width and height your AIR application. It makes sense - an application needs to have a width and height, but for a second, I forgot that I was making an AIR app and not a Flex project.

Just thought I’d post it here in case others get the same problem. This error happens in Flex also, but for other reasons. It’s a little annoying that these error messages are so useless when they could have said something like “Required parameter missing in MXML”...

Using Away3D inside a Flex application or RIA

22 Aug08

I’ve been doing a bunch of Away3D tutorials for Flashmagazine lately. On Flashmag, I’m not focusing on using it with the Flex Framework. It’s rather a set of introductory tutorials. Yesterday I wrote some Flex code after I saw a question about this in the Away3D forums. Posting it here in case others find it useful.

This example is really simple, but here I’ve made a custom component (viewport.mxml) that makes it really easy to add Away3D support to any Flex app. Just drag the component on stage, position / scale the viewport, name the instance and you are ready to go. In this example, I’m also using a standard Flex List control as the texture for the sphere. Clicking in the list will update the texture, but I was unable to use the “interactive” property of the material. Still useful though. Right click the example to get the source.

In the coming weeks, I’ll keep adding Away3D tutorials so if you want to get started with 3D in Flash, drop by Flashmag’s tutorial section. Remember to download the latest version of Away3D either from SVN or the main download page.


We are spoiled!

04 Jun08

I made my first AIR app at Arlanda airport today. Nothing fancy, but it struck me how spoiled we as Flash / Flex developers are. I’ve never really needed a standalone cross platform application until today and now I just made one while sipping coffee and waiting for my flight. It didn’t require me to learn anything new, I just sat down and made it in about one hour.

I’ve done several projector-based applications before, but they’ve mostly been for either PC or Mac. A few have been both, but those have been a real hassle and the APIs have been awkward. The thing with Flash (and now AIR) applications is that we just expect them to work flawlessly across platforms - and they do. Across Mac, PC and Linux they look the same and just do their job. Not only that, they are also powerful, easy to code and deploy. We take this all for granted, but this is really an amazing feat of engineering!

At the Stockholm OnAIR event I was talking to some former Java devs. They apparently didn’t know much about Flex or Actionscript until they were required to learn it at work and they felt a new world open to them as they discovered what they could do. RAD suddenly was fast as in like really fast (compared to Java/HTML/Portals).

Being a Flash/Flex developer isn’t hassle free, but I have a feeling we have a little less to worry about other developers. Don’t we?

An AIR of confusion?

17 Jan08

Adobe AIR, Apple AIR and there’s even Microsoft AIR... What’s next? How about Google AIR - the free, ad sponsored airline?

It looks like Google will support AIR Analytics soon at least?

Cal Evans (Zend) on Flex

11 May07

I recently did a presentation of Flex for the Norwegian PHP users group that went along quite well. I discussed Flex vs Flash and showed examples of connecting to various data sources. One of my colleagues that attended, Dagfinn, sent me a link today to a post by Cal Evans (Zend and PHP guru) and his thoughts about how Flex has made Flash approachable for him. Nice read/tutorial on PHP and Flex and a good title “Flex and PHP: Party in the Front, Business in the Back”!

Getting my head around Flex 2 and the tree control

28 Aug06

Finally had some days to look at Flex 2 again this weekend and discovered some odd things about the tree control that’s worth posting for future reference. I wanted to see how much time it would take to port our CMS to Flex, but I didn’t get longer than adding the tree control. The CMS uses XML that is formatted as nodes with labels and values so I thought I was ready to go. I was wrong. The Treeview refused to display anything but the first node.

Being a noob at Flex 2, I went looking for answers in all the wrong places. I thought it had to be something wrong with the XML since it wasn’t displayed directly (it was after all formatted correctly) so I went through XMLList, XMLListCollection and even making a custom ITreeDataDescriptor. After a lot of fumbling I stumbled upon the resultFormat setting. For some reason, setting this to “e4x” would display something in the tree - it displayed all the XML as the label for every node in the tree… Here’s the odd part: if you set resultFormat to e4x, you have to specify a “labelField”? This in mentioned at the very bottom of the ninth search result for “labelField” in the built-in help. Took me forever to find that information. Something interesting discovered - you can also fix this by specifying a “labelFunction”. In my case, I use it to unescape the XML label nodes because of the Nordic special characters Æ, Ø and Å.

A couple other things discovered is how different XML is treated. It’s really odd for me to access the label attribute of a XML node in ActionScript using “item.@label”, but I guess it’s a good way to do it? e4x is certainly a much better way to work with XML than in former versions of AS. Another thing, unescape(str) no longer converts plus signs to spaces as in former versions. Probably a good thing since “%20” is the technically correct way to encode spaces. Messing with this I discovered the new RegEx classes in AS3. Briliiant! Makes me think back to all that funky string parsing I did with Perl many years ago.

Think I found a bug in the tree as well. If you paste this code into Flex, you’ll see that the horisontal scrollbar fails to display when needed:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute" creationComplete="treeXML.send()">
			public function fixLabel(item:XML):String {
				return unescape(item.@label);
	<mx:HTTPService id="treeXML" url="" resultFormat="e4x" />
	<mx:Tree x="10" y="95" width="196" horizontalScrollPolicy="auto" height="281" id="mytree" dataProvider="{treeXML.lastResult.node}" labelField="@label" labelFunction="fixLabel" />

horizontalScrollPolicy is supposedly set to “auto” by default, but the only way to display it is turning it on permanently?

I could not agree more

24 Jun06

I could not agree more with Ryan Stewart - please do not use Flex to build web sites. Having used Flex a bit now, I see that it can be done easily and that someone will probably do it since the components look so good on screen. I’ll definetly be playing with AS3 and the new Flash Player 9 capabilities (using Flex for coding), but I certainly hope nobody wish to build websites using the application components in Flex.