March 19, 2011 22

Facebook – Invite friends from Flash AS3 – “how to stimulate traffic”

By in Action Script 3, Facebook API, Freebies, Tutorials

The topic of this post is quite self explanatory. Let’s say you have a super extra great application on Facebook and next thing you wanna do is to stimulate the traffic, let people know that your app exists. The ideal situation is to get rid of this job and let users to do it for you. All you got to do is to implement funcionality of inviting users friends and there you go. A virus metaphor is really good to describe what will happen next. We will use new Facebook Graph API. Let’s do it.

facebook invite friends flash

I assume that you know how to create facebook application and I will not cover it here. There are many tutorials on the web so I don’t think there is need to duplicate it. Go grab the source files and take a look at the main actionscript file. Just few lines of code to point out:

Call invitation method:


private function inviteFriends():void
{
    var dat:Object = new Object();
    dat.message = "Let's invite friends for our Super Extra Max Facebook App, more info go to http://blog.ukasz.com";
    dat.title	= 'Super Extra Max Facebook App';
    // filtering for non app users only
    dat.filters = ['app_non_users'];
    //You can use these two options for diasplaying friends invitation window 'iframe' 'popup'
    Facebook.ui('apprequests', dat, onUICallback, 'popup');
}

First we have to create Object to store all data we want to pass to Facebook:

  • message – text you want to appear during invitation
  • title – title of invitation
  • filters – we don’t want to invite users that are already using app, so we’re using this filter

Invitation handler method:


private function onUICallback(result:Object):void{
    if(result == null){
         trace('User closed the pop up window without inviting any friends');
         return
    }
    var invitedUsers:Array 	= new Array();
    invitedUsers = result.request_ids as Array;
    trace('You Have Invited ', invitedUsers.length,' friends');
    //Simple if else if you want user to invite certain amount of friends
    if(invitedUsers.length > 1){
        trace('GREAT, USER IS GENERATING TRAFFIC');
    }else{
        trace('No Good, User invited only one friend.');
    }
}

Now we’re getting fcbk callback which is invited friends list, we treat it as an array and check how many friends were invited. You can place this method at some part of your app, and for example let users play/try again only if they invite at least five friends. Nice isn’t it?

Remember that this will NOT work locally. Source files - facebook friends invitation (708)

October 1, 2010 2

Annoying Mosquitos Animation

By in Action Script 3, Animation, Freebies
Mosquitos Flash Animation

Mosquitos Flash Animation

Did you know that mosquitos can sense you up to 100 feet away? They can also see you,  especially bright colors. They’re  looking for some easy landing, warm place on your body and the game begins. Laying on the bed, trying to fall asleep and all you can hear is little : Bzzzzzzz over your ear… Do you recognize this situation? You probably do unless you’re from Antarctica or sth. What do you feel? Anger, iritation, frustration?

The thing that was always confusing me was – how is it possible that we can send a man on the moon and we can not find any really good solution for those f*** bastards?

For me, the only one benefit from mosquitos is this small animation which was inspired by many hot, summer evenings of frustration. What do you feel when they circle around above your head?

source files - Mosquitos Animation (306) Hope you like it.

Tags: , , , , , ,