Using Flash with open social

Open Social is a google api for social applications across multiple websites. With standard JavaScript and HTML, we can create apps that access a social network’s friends and update feeds.

I have used social api to create the Orkut Application, and found that it’s really very very easy to build orkut app.

Here is the sample app xml which you can use to create your orkut app.

//—– XML Starts from here


<?xml version="1.0" encoding="UTF-8"?>
<Module>
 <ModulePrefs title="____YOUR_APP_TITLE____">
  <Require feature="opensocial-0.7"/>
 </ModulePrefs>
 <Content type="html"><![CDATA[
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="765" height="500" id="____YOUR_APP_ID____(This is name of your swf file with out extention, not orkut application id)" align="middle">
 <param name="allowScriptAccess" value="always"/>
 <param name="movie" value="____FULL_PATH_OF_YOUR_SWF____"/>
 <param name="quality" value="high"/>
 <param name="bgcolor" value="#ffffff"/>
 <embed src="____FULL_PATH_OF_YOUR_SWF____" quality="high" bgcolor="#ffffff" width="765" height="500" name="____YOUR_APP_NAME____" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
    ]]></Content>
</Module>

 

//—–XML Ended

 

Now some points to remember

1. When you copy this code to any editor, don’t forget to replace smart-qoute with standard quotes.

2. As Application is on your domain only use full path like http://www.yoursite.com/yourfolder/yourfile.swf for all images, mp3, js or any file used in your app.

3. Use crossdomain policy file.

//—- Save this as crossdomain.xml and put it on same folder, where your .swf recides

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd“>
<cross-domain-policy>
<allow-access-from domain=”*” />
</cross-domain-policy>

//—

Please update “allow-access-from domain” as per your need.

4. For any commnocation with social api use External Interface.

5. In object tag update “param-name” “allowScriptAccess”, from “sameDomain” to “always”

6. When you update the .xml file use &bpc=1 in URL, it will bypass the Orkut Application XML Cacheing, e.g. http://sandbox.orkut.com/Application.aspx?uid=XXXXXXXXXXXX&appId=XXXXXXXX&bpc=1

Here are some useful Links

 Getting Started Videos (Must see!!!!!!!!!!!!!!!!!!!)

http://www.youtube.com/view_play_list?p=5F0F046F77B7B62A

OpenSocial API Documentation

http://code.google.com/apis/opensocial/docs/index.html

OpenSocial API Developer’s Guide (v0.7)

http://code.google.com/apis/opensocial/docs/0.7/devguide.html

Orkut Documentation

http://code.google.com/apis/orkut/docs/index.html

Orkut Developer’s Guide

http://code.google.com/apis/orkut/docs/orkutdevguide.html

Life’s Little Instruction Book

This sunday I found a wonderful book. Name is “Life’s Little Instruction Book” by H. Jackson Brown, Jr.

It is having 1500+ advices rather instructions. here is some for you all.

Life's Little Instruction Book

  • Compliment three people everyday
  • Watch sunrise at least once a year
  • Remember other people’s birthdays
  • Learn to play any music instrument
  • Buy great books, even if you never read them
  • Learn to make delicious food
  • Be the first one to say “Hello.”
  • Plant a tree on your birthday
  • Make new friends but cherish the old ones
  • Never giveup on anybody, Miracles do happen every day
  • Always put cap back on toothpaste
  • Vote
  • Give to charity all the clothes you haven’t worn during the past year
  • Don’t Smoke
  • Refill water bottle after drinking
  • Think big thoughts, but relish small pleasures
  • Never Cheat
  • Learn to identify local flower, birds and trees
  • Remember peoples name
  • Turn off the TV at dinner time
  • Be your wife’s best friend
  • Show respect for all living things
  • Never cut what can be untied
  • Make video of your parents memories of how they met and their first year of marrige
  • Hire people smarter than you
  • As soon as you get married, start saving for yout childrens education
  • Choose a seat next to the emergency exit when flying. you will get more leg room
  • Remember the ones who love you
  • Remember that it’s better to cheat in price than in quality
  • Be happy for what you have while working for what you want
  • Be grateful thatgod dosen’t answer all your prayers
  • Don’t take good friend, good health or a good marriage for granted

Hope you’ll find it interesting too.

web site of H. Jackson Brown, Jr

Buy this book from Amazon

Fake Gravity Algo

Hi,

This is the fake Gravity algo. I have copied this from book “Flash MX 2004 Game Design”.

//————– Copy from here ——————-

// Object require on Stage

// ball:MovieClip – Idally with a circle or whatever you want.

var ymov:Number = 0;
//
var gravity:Number = 2;
ball.onEnterFrame = function() { 
 ymov += gravity;
 ball._y += ymov;
 if (ball._y>(Stage.height – ball._height)) {
  ball._y = Stage.height – ball._height;
  ymov *= -1;
 }
};

//————– Stop Copying ——————-

Tween Class

Tween class is preety smilple and very very useful. I have not used it till last month and after using it I always think that If I had spend 1hr on this class before 2 years, Icould make many application more interesting. (Specially some Drag & Drops)

Here is one example of Tween Class.

You need to put one movieClip named “mcObject” on Stage and paste the code in Action Layer.

//————– Copy from here ——————-

import mx.transitions.Tween;

import mx.transitions.easing.*;

//

var mcObject:MovieClip;

//

mcObject.onPress = pressHandler;

mcObject.onRelease = mcObject.onReleaseOutside=releaseHandler;

//

function pressHandler() {

//trace(“pressHandler called with [“+arguments+”]”);

this.oldX = this._x;

this.oldY = this._y;

this.startDrag();

}

//

function releaseHandler() {

//trace(“releaseHandler called with [“+arguments+”]”);

this.stopDrag();

var xTween:Tween = new Tween(this, “_x”, Bounce.easeOut, this._x, this.oldX, 5, true);

var yTween:Tween = new Tween(this, “_y”, Bounce.easeOut, this._y, this.oldY, 5, true);

}

//————– Stop Copying ——————-

You can take offical help on Tween class from here