views:

147

answers:

1

I'm writing an Adobe AIR app using plain HTML which needs to upload photos to Facebook. I don't think Facebook's JavaScript/Connect library includes photo uploading functionality, but their ActionScript library does. However, I'm having trouble loading the ActionScript library into the HTML page.

Adobe's documentation describes the process of loading ActionScript libraries into HTML AIR apps, which I tried using the compiled Flash library available here (specifically, Facebook_library_with_AIRConnect_v3.4_flash.swc). So my page looks something like:

<html> 
<head> 
    <title>Hello World</title>
    <script src="Facebook_library_with_AIRConnect_v3.4_flash.swc" type="application/x-shockwave-flash"></script>
    <script type="text/javascript"> 
        // code here...
    </script>
</head> 
<body>
    <div>content here...</div>
</body> 
</html>

But when I try to actually create an object, it can't seem to find the class:

var fb = new window.runtime.com.facebook.Facebook();
// TypeError: Value  is not a constructor. Cannot be used with new.

I'm not sure what's going wrong here, but I had a couple ideas:

  • Is the compiled library file I used the wrong one (do I need a .swf instead of a .swc)?
  • If so, do I need to create my own compiled library somehow from the ActionScript source?
  • Is the namespace I'm using incorrect? (in addition to com.facebook.Facebook() I tried .Facebook(), .fb.Facebook(), .facebook.Facebook(), etc)
  • Should I just give up and try to learn Flex instead?

Any help/insight would be appreciated!

+1  A: 

Well, after a bit more thought I managed to figure it out.

Turns out I did need to load a .swf file. The .swc is a container format, so if you change the .swc extension to .zip and unpack it, you get a .swf file (and a couple other files). I included that .swf file instead of the .swc file and things seem to be working now:

var fb = new window.runtime.com.facebook.Facebook();
// it works!
Alan