Communication between Action Script 3.0 And Server

Some days ago I developed a personal facebook application. In that application, I’ve to communicate between my flash (AS 3.0) game and my server. Now I’ve given the scenario I’ve faced:

Case 1: My target was to develop a dictionary and some simple word puzzle type games. And the application is for facebook.

Case 2: I developed and implemented the dictionary using FBJS (Facebook javascript). For data exchange format between FBJS and PHP I use JSON format (Really a lightweight format). Finally I implemented the dictionary perfectly.

Case 3: Now I chose to develop the games using FBJS. But the problem was, by seeing view source anyone could see the data come from PHP.  So, I decided to use Action Script 2.0 to develop the games. I know AS 2.0 very well but I found there are lot of changes (Core changes) in AS 3.0. So I decided to develop games using Flash Action Script 3.0. As I also want to learn the new trends of AS 3.0.

Case 4. Now I described the problem I faced to develop AS 3.0 games and to integrate them into facebook and how I solved them.

After succesfully developed the game, when data sent to flash from my server, there are 2 ways to do that from AS 3.0
Read the rest of this entry »

Ubuntu – Enable mod_rewrite in Apache server

At first I should define, what is mod_rewrite?
mod_rewrite is a part of Apache server that can rewrite requested urls on the fly.

To enable mod_rewrite in Ubuntu, you just need to write this command in terminal

sudo a2enmod rewrite

After enabling mod_rewrite you can write .htaccess file for your web application.

So what is .htaccess?
.htaccess file provides a way to make configuration changes on a per directory basis. It is a file contains configuration directives is placed in a particular document directory and the directives apply to that directory and all subdirectories thereof.

Some example:

Nice looking URLs (no querying) with pagination:
Suppose your url is: domain.com/article.php?name=title&page=5
You want to change: domain.com/articles/title/5/
Then write in .htaccess file:
RewriteRule ^articles/(A-Za-z0-9-]+)/([0-9]+)/?$ article.php?name=$1&page=$2 [L]

The rule is defined in regular expression. Here [L] means Last Rule. It’s called RewriteRule Flags.

Another example:
Suppose your site has permanently moved to a new domain.
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule  ^(.*)$ http://www.domain2.com/$1  [R=301, L]

Here [NC] means case insensitive and its called RewriteCond Flags. [R=301] means moved permanently. Its called redirection header code.