Thursday, July 2, 2009

I hate error messages like this

TypeError: Error #2007: Parameter blendMode must be non-null.

I was working away on an AIR application and all of a sudden I started seeing this error message. It would show up when I had focus on something and clicked a button that removed the component's parent from the stage. As a result of the error, my app would stop working in all kinds of weird ways. For example, TabNavigators stopped working, but List controls worked fine. Some changes to my display list would work ok while others would result in part of the screen going blank.

I will spare the details of how I figured out what the problem was, but the root cause seemed to be that I was compiling my application with the 3.2 Flex SDK but I was compiling one of the Library projects that I was depending on with the 3.3 SDK.

Setting them all to the same version fixed the problem.

I didn't see any other posts through a Google search of that error, so I figured I would post it here.


Friday, June 12, 2009

It IS possible to do this in an AIR Application...!

A couple hours ago, I posted a question regarding loading classes from a local SWF file. I poked around a bit more thinking that the problem had something to do with the ApplicationDomain. I took another look at the LiveDocs for ApplicationDomain and tried out the example on that screen without any luck. I even commented on the LiveDoc page. I was about to go file a bug but figured I would do one more Google search on the subject. I found this a post at Actionscript.org that seemed to describe the same problem. One on the replies mentioned that he was able to work around the problem by putting a half second delay betweeen the loading of the swf and any attempt to access the classes. So, I took the ClassLoader example from the ApplicationDomain LiveDoc example and added a 500ms delay to the complete handler:

private function completeHandler(e:Event):void {
setTimeout(function(...params) {
params[0].dispatchEvent(new Event(ClassLoader.CLASS_LOADED));
}, 1000, this);
}


After that small change I was able to load the classes from the external SWF. However, this doesn't solve the FlexUnit problem because internally, FlexUnit loads the test classes using getDefinitionByName(). Even if you pass the test cases in as Classes, it gets the qualified name and then calls getDefinitionByName() resulting in the error.

Is this possible in an AIR application?

I have what appears to be a common question regarding a requirement that has come up two of my current AIR application projects. Here is the basic requirement.
The ability for an installed AIR application, to access and load Classes from a separate SWF that is located on the file system
I consider this to be a "plugin" architecture. Let me give you a concrete example. I am working on various AIR projects at any one time. For each I write FlexUnit tests. Because my tests are used to test my AIR applications, they need access to the AIR specific libraries. Rather than compile a unique FlexUnitRunner for each set of tests, I would like to create a single FlexUnitRunner application that allows me to load and run the tests from any of my projects.

I want to be able to have my test projects get built automatically when I change a class in FlexBuilder and then be able to hit a "refresh" button on my FlexUnitRunner application to rerun the tests with the changes.

My initial thought was that I could package my unit tests in a SWC and then have my runner unzip the SWC, pull out the library.swf, load it using RSLItem, SWFLoader or Loader. Then get amd instantiate my TestSuite from that set of tests and run it. This seemed to work in AIR 1.1 but doesn't work in AIR 1.5. The result in 1.5 is always "the Variable PreSaveProcessorTest is not defined"

My second thought was to compile a Module and load that at run time. I can load the module, but I can't figure out how to use AIR specific classes File, FileStream, etc. in the module. There is no option to "include Adobe AIR Libraries" like there is when compiling an SWC.

If I put my tests in a SWC project and reference them from my Module, the module can't use any of my classes that reference File for example. This isn't necessarily needed for my FlexUnit problem.

But if I reference the SWC project from my Module and try to get an instance of my ModuleTestSuite class, I can instantiate it. However I then get a FlexUnit error when I try to FlexUnitCore.run(...) my suite that says: Property metaData not found on ModuleTestSuite and there is no default value.

I have read many articles and posts regarding this, but none do exactly what I want:

Has anyone actually got a working example of how this kind of thing can be done in AIR 1.5?

This RSLItem method is exactly what I was doing in Klok, to allow installation of my 3rd party app connectors at runtime. However, that no longer seems to work.

If someone from Adobe can show a working example that would be really helpful. I imagine there are quite a number of people wondering how to create a "plugin" architecture.

UPDATE: I resolved the issue with the FlexUnit error but I am now back to "the Variable PreSaveProcessorTest is not defined". I think the issue is that FlexUnit is doing a getDefinitionByName() which seems to be the problem.

Tuesday, May 12, 2009

Designing RIAs...the Right Way

Anyone who knows me will tell you that I frequently preach that the only way to successfully design an application that is easy to use and meets user goals is to take a step back and think about it as a whole. I often get pushback with the usual "That sounds like waterfall to me" argument. Like I have said before, it doesn't matter what it is called to me as long as it works.

So the folks at Forrester set out to investigate how to create successful RIAs. The report focuses mostly on Cynergy who is one of the big guys in the field of RIA development (so they know what they are doing). I have to say that I am not surprised by the findings or by the way Cynergy designs and builds applications. To me it seems like common sense. But I am glad that this "official" report calls some attention to it.


Monday, April 20, 2009

Oracle Buys Sun - The future or MySQL

With the news that Oracle is to buy Sun, I can't help but wonder what will happen to MySQL. Maybe it won't mean anything. Any thoughts?

Friday, April 17, 2009

Using Blaze DS in Commercial Applications

A couple of days ago (Apr. 15, 2009) a post popped up on my blog reader titled "Using BlazeDS in Commercial products" which immediately caught my interest. I just assumed that you could use it in commercial products but I have never actually looked into the license. Basically the post indicated that you can't use BlazeDS in commercial products without buying an OEM license from Adobe but you can use it for internal applications. Of course I immediately commented and said that given that, why wouldn't I just always use GraniteDS. I went back a few hours later and found that the blog post was not even there anymore, let alone my comment.

So my question has yet to be answered... If I can't use the opensource BlazeDS for anything but internal applications, why would I spend any effort in every getting familiar with it? 

If you want to read the original post, you can view the cached version here, at least for now.

Friday, March 20, 2009

Arabic Text as a Flex Button label?

The Text Layout Framework that Adobe has made available on the labs site is a very cool display of the capabilities of Flash Player. However, what seems to be suspiciously missing from all the demos is an example of how to use Arabic text on a button. Just putting arabic in the MXML as the button label obviously doesn't work (otherwise... I wouldn't be posting this). What happens is the letters look like they are in reverse order. I can't read Arabic, but I don't think that would make much sense. Especially since none of the letters get connected with the appropriate ligatures.

Looking at the source code for the examples doesn't shed any light on the problem. If you have seen this done please comment with an example.