Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
Download Demo Files (Start & Completed versions for Part 1 & Part 2) In order for the completed code to work you have to put in your Facebook App ID and generated Facebook Social Plugin code in the required fields.
I would also recommend publishing for Adobe AIR 2.6 or 2.7. I have not tested this with AIR 3.0.
In this article, we will look deeper at the ActionScript 3 SDK for Facebook Platform and use some of the API’s to securely log into Facebook, read data from the logged in user, post to the users wall and also post to a public Facebook page.
This article picks up/assumes that you have already registered as a Facebook Developer and created a Facebook application. For more information on how to become a developer and create a Facebook application, click here and/or click here.
I would like to keep the explanations of each step fairly clear and straight forward. Here are the tasks that we are going to accomplish in this article:
- Download and Install the ActionScript 3 SDK for Facebook Platform
- AS3 – Initialize your Facebook Application with your Flash project
- AS3 - Prompt the user to login to Facebook
- AS3 - Post to your wall
- AS3 - Post to a public page
- AS3 - Read the wall of a public page
There are three targets for developing for Facebook: Web(Website and Facebook.com), Mobile, Desktop.
Download the as3corelib.swc Click here to download
The as3corelib.swc contains classes and utilities for MD5 hasing, image encoers, JSON, etc.
Add the .swc's to Flash Professional
Once you download the .swc, in Flash Professional, File -> ActionScript Settings -> Library path (tab) and navigate to the location of the .swc files.
Make sure you change the path to your location of: as3corelib.swc andGraphAPI_Desktop_xxx.swc , if you do not change it, you will get errors.
Once you have added the path to the .swc file, you have access to all of the Facebook/ActionScript API and the
Download the files used in this exercise
Download Demo Files (Start & Completed versions for Part 1 & Part 2)
- Tools.as – used to dump objects and arrays to the output panel or string, making an easy way to read the JSON Facebook data
- NotoFB.as – used in Part 1 – Creating a Facebook Like Button in Flash Professional for Adobe AIR, already has completed code for the Facebook “LIKE” button
The NotoFB.as file will look like this:
Create an init() function. This function will make an initial call to your Facebook application. And also define the event handlers for the buttons on the page. Update the NotoFB constructor function to make a call to the init() function. Make sure you put your Facebook Application ID in the first parameter in the FacebookDesktop.init() function.
To make calls via ActionScript to the Facebook Graph API we use the .api() method. In this case. FacebookDesktop.api(). You can find out more about all of the available Facebook Graph API calls by visiting http://developers.facebook.com/docs/reference/api/ and there is also an interactive Graph explorer (https://developers.facebook.com/tools/explorer ) that allows you to test calls to your app. One thing to keep in mind, by visiting the Facebook Developer docs it does not base their examples for ActionScript. We use the Graph API and insert it into the FacebookDesktop.api() method. So you must review the Facebook Developer Graph API documentation, as well as the Facebook ActionScript SDK.
The code below uses the Tools.as file to loop through the JSON so it is easy to read. I downloaded the original Tool.as from here, but the one using in this project has been tweeked a little.
The final code is here:
Save/Test your movie.
- Click on Login, enter your credentials
- You can Post on your wall, you can post on a page wall (Change the id in the onGet/onPagePost to post to another page)
- You can read a page’s wall
From my small start as a Flash 3 (whatever you call it back then) to an ACP, ACI and everything else. I am thrilled and honored to have been chosen as a Adobe Community Professional. I look forward to continue to assist the community with questions/concerns/comments on Flash, ActionScript, and anything else I could help out with… You can view other ACP’s in around the world, here.
Feel free to contact me: Twitter @thesminc Email: email@example.com
Through my travels as an instructor, I always get the question, What is a Document Class? Well the answer is simple, but the possibilities are extreme. During this article, I would like to explain some of the most important things to know about a Document Class….Mainly a Document Class is “Your SWF file”!
First of all, the document class is optional. Ok, it’s 2011, most seasoned Flash Developers are NOT using the timeline anymore and are using the Document Class. And every year as someone reaches excellence, there is someone born…New to Flash/ActionScript. Someone, right now, is holding on to the timeline, as if their life depended on it. So, whatever category you may fall into, one thing is certain, Flash is OPEN to you. Flash will let you do, pretty much, whatever you want.
- Create animation and ActionScript on the timeline
- Create animation without the timeline, using ActionScript
- Create animation with AND without the timeline, together…
You do not have use a Document Class, but you should at least understand it.
One of the reasons why you should understand it:
- 99% of all of the examples in the Adobe Help Docs, online articles and many books are written using a document class.
So, if you would like to leverage the power of “learn by example”, then you need to know, if nothing else, NOT how to WRITE a document class, but how to USE a document class.
So first things first, without getting too complicated.
- Part 1. Two of the main uses of a Document Class
- Part 2. Implement a Document Class.
Here are two of the most important topics when working with the document class?
- Separate your code from the timeline
- Let your SWF file become a Sprite vs a MovieClip
Separating your code from the timeline
I mentioned, the document class is optional. You can have the same functionality with code running on the timeline and in the document class. The rule of thumb is if you want your ActionScript to be more portable, easier to update, and free from you FLA, then use a document class. Take a look at the code below.
ActionScript on the Timeline inside of an FLA.
The ActionScript below draws a red circle on the stage with an x/y = 100 and radius = 50.
ActionScript on in a Document Class.
The ActionScript below draws a red circle on the stage with an x/y = 100 and radius = 50.
Both of the options above give us the same results. As you see, there is more ActionScript that must be written in a Document Class, but it’s well worth the time. Next, I will discuss one of the benefits of using a Document Class.
Your SWF as a Sprite not a MovieClip
This may or may not be a surprise to you, but by default an SWF file is nothing more than a MovieClip. Yes, that’s right, a MovieClip. A MovieClip that contains other MovieClips, bitmaps, symbols, video, text, etc…. With that being said, a MovieClip is a very powerful symbol, actually, the most powerful symbol. The thing that makes a MovieClip unique is the timeline. The timeline allows you to create linear animations and also create linear dynamic functionality with ActionScript on keyframes.
Enter the Sprite Object.
The Sprite object, in all simple terms, can be considered a new symbol in Flash. The only thing is that when you are converting a shape to a symbol, Sprite is not an option. Your available options are, Graphic, Button, and MovieClip. There are many ways to use Sprite objects in Flash, but our conversation here, is just focusing on the Document Class.
The main thing to remember about the Sprite Object/Symbol/Class is:
- The Sprite is identical to the MovieClip. Except for one thing… The Sprite does NOT have a timeline.
In many cases, when we use MovieClips, we do not use the timeline in that MovieClip. And in cases like these, the timeline is actually taking up unnecessary resources. For this reason, Adobe created the Sprite class, to give us the ability to have the same power of the MovieClip, but not have to worry about the resources consumption that comes along with a MovieClip.
So now by using a Document Class, your SWF file can actually be a Sprite vs a MovieClip. Once again, look at the code below. On line 5, “extends Spite”, will make your SWF file become a Sprite. Note: A Document Class can ONLY be a MovieClip or a Sprite.
In part 2 of this article, I will discuss how to implement and use a Document Class.
It’s 2011 folks, times are changing, Change We Can Believe In?… Ok, I’m not running for President, but sounds like a good slogan.
First of all, I’m not your normal user….I’m a UberTechie…I have, to have the latest gagets, the coolest clothes and be in the know with the latest trends… I have multiple cell phones for development, Android, BlackBerry and iPhone. So with that being said..I may be able to give the average consumer some advice..
So Google announced the ability to port your phone number to Google Voice. What does that mean?
Well, let’s say my phone number is 999-9999 and I have two cell phones, a landline, and many IMs (GTalk, AOL, BBM, etc). I really do not need to go into depth, but you can understand the complexity, that multiple ways to communicate can cause. So enters.. Google Voice, hereafter referred to as, GV (my lawyer lingo).
So, GV without porting, allows you to create a new number(???-????) and “link” it to your cell phones, land lines and a few IMs. So when someone calls your GV number, it will connect to all of the phones that are “linked” to that number. I’ve used GV with this setting and I have really enjoyed it. The only thing is that I really never gave anyone my GV number. Now, I could have used it for business, friends, or whatever. But I did not.
So, now as of January 2011, Google now allows you to use your “everyday” number as your GV number. So when someone calls my 999-9999 number, it will connect to all of my “linked” numbers. So what’s the big deal?
Let’s look at the “pros”.
- Always keep your phone number, regardless of your device. (Love BlackBerry for build and service, love Android for flexibility, love iPhone for continuity)
- I have two cell phones (777-7777 and 888-8888), now when someone calls my 999-9999 number it will ring both phones(777 & 888). So I can leave my Droid at home and take my BlackBerry or vice versa. (My BlackBerry looks better with my suit, like my Armani watch vs my Nike Watch, think about it…..)
- Or I can, at anytime, select which phones will ring and which phones will not.
- Select (via your contacts) which phone rings. So create a Group and have that group forward to your BlackBerry and have another group forward to your Android.
- I love to text, but I hate to text on my phone…. With GV Porting, I now can text from my computer vs my cell phone. Hence, I type 65+ wpm, so you can imagaine how eaiser it is to Type & Text, then to Touch & Text.
- Personalize voicemail for callers.
- If I’m in front of my computer and the phone rings I can answer the phone on my computer. Yes, click “Answer” and start talking…
- I’m not even touching the cheaper Long distance rates……
- Become that true Playboy, businessman or UberTechie.
Let’s look at the “cons”.
- It costs $20 (may not be a “con” if you are someone like me). And if you are not careful, can cause you an early termination fee.
- Forces you to manage multiple devices, landlines, etc
- GV can be a little confusing. You have to get in the mindset that “In” means GV and “Out” mens your number.
- GV can handle your Text Messages and VocieMail, so your cell phone will get multiple notifications. One text message can trigger multiple notifications on your cell.
- Look unorganized to your friends for having more than one cell phone.
- Become that true Playboy, businessman or UberTechie.
- I may be missing a few more (let me know in your comments)
All in all, GV porting is worth checking out. When I wake up, I have a choice of suits, shirts, watches, and even underwear….why not phones.
It may not be something you are ready for now, but in the future… It may be part of our everyday life.
The XML below is called blackberry-tablet.xml. It should be generated automatically when creating a new project. But if you do not have this file, you can create one using your favorite HTML editor.
To apply a custom icon:
Add this line to the XML
To apply a custom splash image:
Add this line to the XML
Also, I noticed that if you leave <transparent>true</transparent>, then your application will be transparent and you will see the desktop of the Playbook behind your app. (May be useful)???
The new BlackBerry Playbook SDK has been released. There are a lot of changes to the simulator and SDK. Renaun Erickson created a video explaining some of the changes. You can view the video below.
As with all programming, we run across some errors that we just cannot easily figure out. When dealing with FlashBuilder, one way to “start with a clean slate” is to perform a “Clean”. By doing this, at least you know that your Flash Builder project is recompiled with all of the latest and previous assets. And if you get an error after this? Well, time to check your code.
To perform a “Clean”:
- Go to “Project” menu.
- Select “Clean”
The Google TV is game changing!
Thanks to (Adobe/Google/Logitech) for offering it as a Giveaway to Developers!
I had a few reservations about this device before receiving it. ( Just because I had no idea what it did.)
What do I need it for? Am I really going to use it? Can App development grow on this platform? Will I get all of my channels?
Well, after receiving the Logitech Revue and unboxing. Once the physical connections were made, there were 12 easy steps to follow. First of all, since this device was going to be on our main TV set, I decided to create a “family” Gmail account that the entire family can use. I can use this account to pull all of our shared YouTube videos, Picasa photos, etc., in one centralized account.
I am impressed with the device/component integration, but that’s to be expected from Logitech. The Revue picked up my Verizon cable box, my HD TV and my Audio receiver. So, even before I interacted with Google TV, I had a very cool universal remote control! The entire setup process lasted about 15-20 minutes, but it was very smooth and direct. (for me at least).
I kept hearing all this chatter about NBC, CBS, etc, pulling their content from Google TV. This made me think that I actually would NOT get these stations. (I know that may sound crazy) But they are actually blocking the web/video content. But WHO CARES, I’m on a TV? Duh? With DVR & onDemand? Duh? I doubt I would have visited their sites anyway. It’s really worse off for them, because they are leaving themselves out of a whole new wave of entertainment and reach. I’m glad to know that Google isn’t “web blocking”, unlike some other software companies that control what you can view.
I’ve also heard a lot of chatter about Google TV not having many Apps. But if you remember the original iPhone, we went about a year and a half before we got anything close to Apps. At least with Google, you know it’s only a matter of time. (Short time).
After, the setup was completed, the Revue rebooted and the Google welcome screen appeared. The first thing I did was go to YouTube. I had to see how well the videos played on my screen as well as the quality. Upon, visiting the youtube.com site on Google TV, I was prompted to use YouTube Lean back. A sort of scaled back, but extremely powerful version of You Tube. And since I also have a Android phone, I downloaded the YouTube Leanback App, to connect and control the video playback. Overall, the video playback was very smooth, but the quality was about the same, unless you choose a HD video. So I watched the Kayne West – Runaway Film, the quality was good and having the Revue connected to my AV Receiver the sound was great, adding a lot to the experience.
Next, I visited a few websites, logged into the Pandora app, checked out some of the settings (which is very similar to our Android devices), and actually set my DVR from within the Google TV app.
Another thing that I like is the ability to search for a TV show that you may want to watch. This beats channel surfing! The search capabilities are great and it also give you an option to search TV or the web.
So my main purpose that I see for Google TV, (for me at least), is the fact that I can now watch TV without my computer in my lap! The surfing experience is great! And when my wife and I are debating about some actor, movie, song, or whatever, Google is right at my fingertips!!
Overall, you may see Google TV on the web, or in your local Best Buy, but until you use it (and each of us will use it differently), you do not know what you are missing.
Give it a try, demo, or buy!
During my wonderful time at Adobe MAX, I had the pleasure running into Mike Potter of Adobe Developer Relations. We sat down for a few minutes to talk about Mobile Development using the Flash Platform. Check it out below. (I’m at the 2:00 mark)