Archive for the 'AIR' Category

AIR 1.5 debugging issues.

When I push debug on my fancy new Flex Builder 3.0.2 it doesn't launch my AIR application. The console stays blank and it hangs there indefinitely 19 times out of 20. Occasionally it will actually launch and debug the application. I uninstalled FB and rebuilt it with the 3.0.2 update... Still no joy.

So I am sitting here trying to fix the countless errors the new AIR 1.5 has introduced to my application. I have angry users, and my app refuses to debug. I wish I could use AIR1.1, but the automagic update yesterday insured that all my users updated to 1.5. Pushing my monitor off my desk and calling it a day is an attractive option, but I know the relief would be temporary, at best.

Anybody else have problems debuging with the update? Better yet, anybody have a solution? My monitor would appreciate it.

Flex Date and Time (datetime) Picker Control

I saw one of these at some point, but couldn't find it when I needed it again. Pretty simple, the control has a property called selectedDate that returns a date object represented by the selected date and time. You can also feed it a Date and it will adjust to that. It is on a 12 hour clock. It dispatches a change event (Event.CHANGE) as a new date/time is selected.

There is an Inspectable property called minuteIncrement to adjust the increment on the minute stepper. I couldn't figure out how to have double digits on the 0-9 minutes. If anybody knows how I might achieve that, please let me know.

Here's the Source

Django Authorization from Flex/AIR via PyAMF

Django views serve nicely as service end-points for Flex applications. Here are some notes on maintaining authenticated sessions between a Flex/Air/Flash application and your Django backend.

gateway.py

from pyamf.remoting.gateway.django import DjangoGateway
 
import myproject.myapp.views as views
 
gw = DjangoGateway({
    'login'                       : views.login_user,
    'logout'                     : views.logout_user,
})

views.py

import pyamf
from django.contrib import auth
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
 
try:
    pyamf.register_class( User,  'django.contrib.auth.models.User')
except ValueError:
    print "Classes already registered"
 
def logout_user(http_request):
    logout(http_request)
 
def login_user(http_request, username, password):
    user = authenticate(username=username, password=password)
    if user is not None:
        login(http_request, user)
        return user
    return None
 
@login_required
def registered_user_protected_function(http_request):
    return "You are a registered user."
 
@login_required
def staff_protected_function(http_request):
    if http_request.user.is_staff != True: return None
    return "You are staff."

from flex

var netConnection:NetConnection = new NetConnection();
netConnection.connect("http://mysite.com/gateway");
var responder:Responder = new Responder(loginResult, handleFault);
netConnection.call("login", responder, "username", "password")

The http_request carries a reference to the currently authenticated user throughout the session. This works for web based Flex application as well as AIR applications on the desktop. Note that I am using a try/except on the pyamf class registration calls. Because this is session based, the classes only need to be registered once. Without the trap, it throws a TypeError letting you know the registration has already taken place.

Django User Authentication Documentation
All of the various things you can do with authentication in Django. It is, of course, based mostly on the use of the very nice Django HTML template system. While those bits aren't handy to the likes of us, it is a good read either way.

pyAMF ByteArray example
This example shows the basic structure for setting up Django/Flex communication. It doesn't cover authentication, but covers a good bit of territory with examples in Flash and Flex.

Integrating Adobe AIR, Cairngorm, PureMVC, LiveCycle Data Services (LCDS), MySQL and Hibernate

This post is going to cover the use of Adobe AIR, PureMVC, cairngorm, MySQL, LiveCycle Data Services (LCDS), and Hibernate. It utilizes these tools to create a simple image management system. The focus is on the configuration of the server to integrate Hibernate with LCDS and access that configuration from an AIR client.

Continue reading 'Integrating Adobe AIR, Cairngorm, PureMVC, LiveCycle Data Services (LCDS), MySQL and Hibernate'

BlazeDS, Vista, and Streaming AMF Channels - For the Children

Maybe this isn't true for every installation of Vista, but we were having a helluva time tonight getting BlazeDS streaming AMF channels to communicate from an AIR client running on Vista. We were just trying to use the default example chat application to do some testing with AIR. It works great on XP, no problem at all. I sent out the little client to 4 or 5 people and it worked just as expected - that is until it hit a Vista machine (dum dum duuum).

Vista wouldn't connect at all, blank, nothing. I added some error checking to the application and it simply reported back that it couldn't connect. What the hell? My initial assumption, which turned out to be [edit] not so [/edit] correct, is that maybe Vista just sucks. After hours of combing the internet for The Answer™, I was having no luck what-so-ever.

Finally it occurs to me to check the Tomcat logs. Hey, a clue!

 [BlazeDS] [ERROR] Endpoint with id 'my-streaming-amf' cannot service the streaming request made with  HTTP 1.0. Only HTTP 1.1 is supported.

That's weird, you'd think the MOST ADVANCED OPERATING SYSTEM KNOWN TO MAN (this is a joke, calm down linux/OS X aficionados) would be using the current protocol, and not something relegated to Windows 98 and IE 5.5. At least now I have something to search for, and search for, and search for...

There was one mention on Christophe Conreate's blog, but no solution was provided. The BlazeDS DevGuide on Scribd mentions the following:

The streaming AMF and HTTP channels are HTTP-based streaming channels that the BlazeDS server can use to push updates to clients using a technique called HTTP streaming. These channels give you the option of using standard HTTP for real time messaging. This capability is supported for HTTP 1.1, but is not available for HTTP 1.0.

This seems reasonable. AIR is advanced technology. It should be using the current standard in HTTP protocols, but why is Vista screwing me around? Getting desparate I am throwing out edge case searches and find this gem on techalicious.tv about 'hacking' IE7 to allow more than 2 downloads at a time.

HKEY_ CURRENT_USER\ Software\Microsoft\ Windows\Current Version\Internet Settings

Hey, what's that? A reg key marked EnableHttp1_1 - which on my XP Machine is set to 1. Guess what it was set to on the Vista machine? 0. Yes, HTTP 1.1 was completely disabled. The key ProxyHttp1.1 was also set to 0, which isn't a key on XP. We had checked in Charles, and all browsers including AIR were using 1.0. This made a lot more sense after the regkey was discovered. After a reboot everything works fine.

This setting can be changed without hacking the registry in the control panel under Internet Options>Advanced>HTTP 1.1 Settings. User Error? Safety Conscious OS defaults? Switch happy application install? I don't know.

If somebody could provide an explanation of what might have caused this, or if by some off chance somebody reading this is actually using Vista could check this key and see if it is on or off, it would be appreciated. Otherwise I am baffled, yet really really happy to have squished this particular bug.

Onward.