Wednesday, August 26, 2009

Adobe InContext Editing problem with SIFR

I recently had an opportunity to try out InContext Editing on a client project. Of course, 5 minutes after hooking it up I ran into a problem. If you happen to be using sIFR to add nice typography to your site, you will notice two problems.
  1. First, the sIFR Flash content appears to be in front of the InContext Editing interface;
  2. Second, the sIFR replaced text is not editable. If you make an editable region around sIFR replaced text, you get an error when you edit the page.
Luckily, there is a simple solution to the problem. If you open up the sifr.js file you will immediately notice that the Javascript is compressed in such way that it is pretty unfriendly. However, since luck is on our side, the only line you need to edit is human-readable. Scroll to the bottom of the file and you will see a line that looks like this:

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)) {

That IF statement checks to make sure sIFR is ready to be setup. In our case what we want to do is make sure that that condition checks to see if you are in InContext Editing. We can tell by looking at the top.document.location to see if the page that is currently in the location bar is the ice/ide.html page. Changing the condition above to:

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100) && top.document.location.toString().indexOf("ice/ide.html") <= 0){

Doing so will cause sIFR to be enabled unless you are in the InContext Editor...problem solved.


Monday, August 24, 2009

Vista 64 bit and Type 1 fonts

I came across a weird problem today where after installing a Type 1 font, it was still not available in Illustrator or Photoshop but was available in MS Word. It turns out that you need to install it in the normal fonts folder and put it in C:\Program Files (x86)\Common Files\Adobe\Fonts as well.

I don't know if this violates any font licenses so you should verify that you are allowed to have two copies installed this way.

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?