Category Archives: Air

Develop Flash Player 11 and Air 3 Applications (Desktop and Android)

If you haven’t heard already, Flash Player 11 and Air 3 were announced and released at Adobe Max earlier this week. Since it’s out to download, why not take advantage of staying updated and start making cool applications with these new API’s.

Download these files
- You need the AIR SDK

http://blogs.adobe.com/flashruntimereleases/2011/10/04/flash-player-11-and-air-3-now-available/

- You need the PlayerGlobal (.swc)

http://www.adobe.com/support/flashplayer/downloads.html#fp11


Update Facebook Status from Android Air Applications with Extended Permissions

Before I go into details about this exciting experiment with AS3 Facebook API and Android Air, I want to give credit to a few websites.

(The code that I used was from the first source, but used second source as a reference)

http://blog.flash-core.com/?p=233

http://blog.yoz.sk/2010/10/authorizing-facebook-applications-in-android/#more-2481

One of the coolest things about making games, is being able to post to social networks on how well you did. I’m in the middle of developing a Android Air/iOS application and since I’ve developed most of the functionality for the game, I wanted to implement this feature. After numerous hours of searching online and trying different workarounds, I finally made it work! For the purposes of testing, I used the Flash Web Application that I made for this experiment. One of the coolest things about making it work on the Android, you don’t need to change anything or create a new application in Facebook.

Below is snippets of the code that makes this feature work.

_view = new StageWebView();
_view.addEventListener(LocationChangeEvent.LOCATION_CHANGING, viewChangingHandler);
_view.addEventListener(LocationChangeEvent.LOCATION_CHANGE, viewChange);
_view.stage = stage;

_view.viewPort = _space;

var _sAppId:String = "";

var _sRedirectUri:String = "https://graph.facebook.com/oauth/authorize?client_id=_sAppId";

var _sScope:String = "publish_stream, create_event, rsvp_event, sms, offline_access, manage_pages, email, read_insights, read_stream, read_mailbox, ads_management, xmpp_login, user_about_me, user_activities, user_birthday, user_education_history, user_events, user_groups, user_hometown, user_interests, user_likes, user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos, user_relationships, user_religion_politics, user_status, user_videos, user_website, user_work_history, email,publish_stream,offline_access,read_stream";

_view.loadURL("https://graph.facebook.com/oauth/authorize?client_id=_sAppId&scope=publish_stream, create_event, rsvp_event, sms, offline_access, manage_pages, email, read_insights, read_stream, read_mailbox, ads_management, xmpp_login, user_about_me, user_activities, user_birthday, user_education_history, user_events, user_groups, user_hometown, user_interests, user_likes, user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos, user_relationships, user_religion_politics, user_status, user_videos, user_website, user_work_history, email,publish_stream,offline_access,read_stream&redirect_uri=http://www.griffinsdesigns.com/Facebook");

private function viewChangingHandler(event:LocationChangeEvent):void{
event.preventDefault();
_view.loadURL(event.location);

}

private function viewChange(event:LocationChangeEvent):void{
var _sRedirectUri:String = "https://graph.facebook.com/oauth/authorize?client_id=_sAppId";

var _sAccessToken:String;
if (_view.location.indexOf(_sRedirectUri) == 0 && _view.location.indexOf("access_token")!=-1){
_sAccessToken = "?"+_view.location.substring(_view.location.indexOf("access_token"), _view.location.indexOf("&expires_in"));
_view.stage = null;
}

}

Make sure you use loadURL, otherwise it will give you an error. The sources listed above, post, “load(new URLRequest( “. That does not work with the newest Air. If you look at my previous article about posting to Facebook, I mention a long URl that you want to redirect to, you want to use that URL as your URL that you will load.

What does this code do?

This code makes a web frame inside your Android Application and will show the Facebook Applicaton. If a new user goes to your application, the frame would show a login screen, like if they want to Facebook from a browser. After the user logs in, they would be sent to a page that lists the extended permissions (assuming you set the application to have extended permissons). Once the user clicks the allow button, they would be sent to the application.

I haven’t tested this on a Android Device. I only tested it by publishing it in Flash. The next thing I need to test is seeing if it would work when publishing it to a iOS application and test it on my iPad 2.

Facebook login screen inside Android Air Appliation

ExtendedPermissions in Android Air


Flash and HTML5, Coexist?

In my opinion, basing from the features in the new Master Suite CS5.5, I think Flash and HTML5 could coexist in the future. The new Master Suite seems to mainly focus on the ease of developing and designing mobile applications and tablets. In the future, when HTML5 becomes more widely supported, I think Flash would be mainly used for mobile applications and desktop applications. HTML5 would take over animation, video, and audio for the web.


Making Android Applications from Flash

As we all know, mobile applications are more popular than ever. I thought it would be cool to make my own Android application.

I’ve heard that Flash is capable of publishing Android applications, so I thought I try the accelerometer feature that smart phones have. After going to the publish menu, I didn’t see anything related to publishing to Android. After some searching, I figured out how to publish Android applications. Since I had trouble figuring out how to publish Android Applications from Flash, I thought other people would have problems with that too, which is why I’m making a post about it.

1. Download the Air Extension, Android Air SDK, and Android Manager.

http://labs.adobe.com/downloads/flashpro_extensionforair.html

http://www.adobe.com/products/air/sdk/

http://developer.android.com/index.html

2. Open Flash, and click new. Select Air 2.

3. Make your application. Depending on your application, you may or may not need to use the Air Android SDK. In the Android Manager, their is a emulator to test your application. If you have Adobe’s Device Central software, that works too for testing.

4. Go to file, and select Adobe Air 2.5 settings.

5. Click the Signature tab, and make your own certificate.

6. Then click the General tab. Fill out all the information for your application. Then click OK.

7. Then click File, and open the publish settings. In the player, click Air for Android.

8. After that, click publish. You should have a file with a .APK extension. That is your Android Air Application. Now you just have to post it to the Android market for everyone to play! The phone needs to have Adobe Air installed for it work!

If you are interested in doing Android Development with Flash, I would recommend the Blueprint Guide for Android Development with Flash book. That book has a lot of good information. I don’t receive any money for talking about it in my blog.


Tweetr Air Application

One of the Air Applications that I’ve been working on is making a Twitter application using Tweetr. Later, I’ll post a working sample. Below is snippet of my source code to get you going.


import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.events.TweetEvent;
import flash.xml.XMLDocument;

var _twit:Tweetr;
var _xml:XML;

_twit = new Tweetr;
_twit.useAuthHeaders = true;
_twit.username = _userName;
_twit.password = _userPass;

_twit.getFriends();
_twit.addEventListener(TweetEvent.COMPLETE, friendHandler);

function friendHandler(event:TweetEvent):void {
_xml = new XML(event.data);
}

For more information and to download the library:

http://wiki.swfjunkie.com/tweetr


Follow

Get every new post delivered to your Inbox.