Tushar’s Blog – BETA


Getting Start with Flash based Virtual World

Posted in Flash, Games by Tushar Vaghela on September 24, 2009
Tags: , , ,

Developing Virtual World is a huge task, but if we break the task list, here is first step.

In this example I have integrated SmartFox with OpenSpace.

Software Check List
1. SmartFox Server (http://www.smartfoxserver.com/products/)
2. Open Space Engine (http://www.openspace-engine.com/evaluate.php)
3.IIS or any local server i.e. WAMP (http://www.wampserver.com/en/download.php)

  • Install SmartFox (You can install any version of SmarFox Lit, Basic or Pro)
  • Start SmartFox Server. Programs-SmartFox Server-Start SmartFox Server
  • Start Admin Tool.  Programs-SmartFox Server-Admin-Admin Tool
  • Login Using Default Setting Server IP 127.0.0.1, Port 9339, User Name sfs_admin, Password sfs_pass
  • Click Config.xml Tab
  • Under Zones Tag Add the Following


<Zone name="openspace" uCountUpdate="true" maxUsers="200" customLogin="false">
<Rooms>
<Room name="Ranch (inside)" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
<Room name="Ranch (outside)" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
<Room name="Slopes area" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
</Rooms>
</Zone>

  • Extract the “OpenSpace_trial.zip”  and go to the following folder “\OpenSpace_trial\OpenSpace_trial\Examples”
  • Copy “FarWest_Ranch” and “Slopes” to loacalhost root. (C:\Inetpub\wwwroot)
  • Open Your browser and type “http://localhost/FarWest_Ranch/OpenSpace_tester.html” or http://localhost/Slopes/OpenSpace_tester.html” and see your character moving into virtual world.

You can edit the world using Editor Which is Located at “\OpenSpace_trial\Editor\OpenSpaceEditor_trial.air” (You need to install it)

You can edit avatar by editing following file “\OpenSpace_trial\OpenSpace_trial\Examples\FarWest_Ranch\libraries\AvatarsLibraryExample.fla”

Shuffling Array in Flash

Posted in Flash by Tushar Vaghela on December 10, 2008
Tags: , ,

We often need to shuffle array in flash but flash is not having any in-built function to shuffle the array.
Here is code to shuffle the array in a simple manner.

Please convert smart quotes to normal quote before pasting the following code to flash

// Initinal Value of the Array
var aData:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

trace(‘Before Shuffling : aData = {‘+aData+’}');// Before Shuffling : aData = {1,2,3,4,5,6,7,8,9,10}

for (i=0; i<aData.length; i++) {

//This will fetch the value at random index and save it in nData
var nData:Array = aData.splice(randRange(0, aData.length-1), 1);

//This will store the nData value to end of the same array
aData.push(nData[0]);
}

trace(‘After Shuffling : aData = {‘+aData+’}');// After Shuffling : aData = {5,6,1,3,7,10,2,9,8,4}

function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}

Using Flash with open social

Posted in Open Social by Tushar Vaghela on June 26, 2008
Tags: , , ,

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

Posted in Books by Tushar Vaghela on June 19, 2008
Tags: , ,

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

Posted in Books, Flash, Games by Tushar Vaghela on June 5, 2008
Tags: , ,

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

Posted in Flash by Tushar Vaghela on June 3, 2008
Tags: , ,

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

Jump Algo in Flash

Posted in Flash, Games by Tushar Vaghela on May 31, 2008
Tags: , ,

Hi,

I could not fullfill promise that I’ll post daily but I am trying…..

This post is for Flash Developers who are doing game programming.

Open new Flash File, Create one MovieClip and Paste this code on MovieClip (Bad Practice, but focus on what it’s doing)

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

//This is settign the initial values onLoad
onClipEvent (load) {

//Speed of the Object
//More Speed will make object go higher in sky....
//This can be mass of the object
startspeed = 10;
//Amount of Gravity, 9.8 is standard Gravity
//Use 0 as gravity and your object will be lost in space
//Will never come down...
//Can be used for animated background, with some random wind algo.
gravity = 9.8;
//Current Status
jumping = false;
//Initial position
startpos = 0;

}
onClipEvent (enterFrame) {

//If user press up key and object is not jumping
//This will make object jump
if ((Key.isDown(87) or Key.isDown(Key.UP)) and jumping == false) {

jumping = true;
starttime = getTimer()/1000;
startpos = this._y;

}else if(Key.isDown(Key.LEFT)){

_x -=5;

}else if(Key.isDown(Key.RIGHT)){

_x +=5;

}
if (jumping) {

time = getTimer()/1000-starttime;
_y -= (startspeed-gravity*time);
if (_y>startpos) {

_y = startpos;
jumping = false;

}

}

}

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

This code is taken from http://www.video-animation.com/flash_06.shtml

Sunday

Posted in Sundays by Tushar Vaghela on May 18, 2008
Tags: , ,

Hi,

Today was busiest sunday of my life. We have planned to manage our home since we have shifted here on last month but house was such a mess till today.

We planned to fix every thing which was like….

 Home on 5/18 Morning

and after spending hrs. it’s now …

Home in the Noon

Beside this we have washed 1000’s of cloths, and hang out with friends in great cafe nearby my house.

I know no one likes to know what I did this sunday (or any sunday or may be any day), but I have posted it cause I want to post it..

Game of the Week

Posted in Games by Tushar Vaghela on May 17, 2008
Tags: , ,
Games at Miniclip.com - Shanghai Mahjongg
Shanghai Mahjongg

Clear the board of stones by finding all the matching pairs.

This game was there in my 8-bit video game collection, but I could never figure out how to play it and as Mario is my all time favourite, I never tried hard to learn the game play. But today I am playing this game as part of my work and I must tell that this is the wonderful game and you should also try your luck with it….

Book I am reading …

Posted in Books by Tushar Vaghela on May 16, 2008
Tags: , , ,

The 3 mistakes of my life

I am currently readind Chetan Bhagat’s new “The 3 mistakes of my life”, I am in middle of the book and so far I think this book is not as good as the previous ones but sill I like the book cause it’s directly touching my heart – it’s Ahmedabad’s story. I know the places they are talking about, I have gone through earthquake, riots & all….. I don’t think it must read book but it’s good book.


Now I have finished the book and want to update my views, but will do it later.

Next Page »