Monday, 18 April 2011

Blur guess game in AS3 part 1

In this tutorial you will learn how to create a Blur guess game in Actionscript 3. In this game you will see blurry images and you need guess the name object in the blurry image. For this tutorial you will need logo images, I have used famous brand logo which can be downloaded at:

Update: Blur guess game part 2

Blur guess game in Actionscript 3

Step 1

Open a new AS3 file and import your images into the stage by selecting File > Import > Import to stage. Before you import your images, make sure they are the same width and height. My images dimensions are 100x100 pixels. You can use Photoshop or a similar program to edit the dimensions of the images.

Step 2

Arrange the images on the stage, so that there are in 3 columns like below. And convert them into movie clips with the instance names: youtube_mc, mastercard_mc, ibm_mc, canon_mc, shell_mc and bmw_mc.

Step 3

Select the Text tool with input text and drag a text field on the stage. Give the instance name: input_txt. Then drag another text field, but this time with dynamic text and give the instance name: found_txt. You will need to embed the numerals and a ‘/’ (forward slash) glyphs.

Step 4

Open up a new AS3 class file save the file name as ‘BlurGuess’ and add the following code.

package {

 import flash.filters.BlurFilter;
 import flash.display.*;
 import flash.utils.setTimeout;

 public class BlurMatch extends MovieClip {

  private var wordsMcArray:Array = new Array  ;
  private var strArray:Array = new Array  ;
  private var mcCheckArray:Array = new Array  ;

  private var counter:uint = 0;
  private var totalWords:uint;
  private var cols:uint = 3;
  private var xOffset:int = 133;
  private var yOffset:int = 122;

  public function BlurMatch() {

  private function init():void {
   wordsMcArray = [youtube_mc,mastercard_mc,ibm_mc,canon_mc,shell_mc,bmw_mc];
   strArray = ["youtube","master","ibm","canon","shell","bmw"];
   mcCheckArray = [];

   counter = 0;
   totalWords = strArray.length;

   //Displays the number of correct words answered and set the focus to the input text field.
   found_txt.text = String(counter) + "/" + String(totalWords) + "correct";
   stage.focus = input_txt;

   for (var j:int = 0; j < wordsMcArray.length; j++) {
    //Adds a blur and outline to each of the image
    wordsMcArray[j].filters = [new BlurFilter(15,15,3)];

    var outLine:Shape = new Shape  ;,0x000000);[0].x + xOffset * j % cols,wordsMcArray[0].y + yOffset * int(j / cols),wordsMcArray[0].width + 2,wordsMcArray[0].height + 2);;

   //Adds the change event to the input text field.

  private function detectKeys(e:Event):void {
   for (var i:int = 0; i < strArray.length; i++) {
    if (strArray[i] == input_txt.text.toLowerCase()) {
     //If the correct word is typed then the counter gets incremented and the
     //found displayed is updated to show a word has been found.
     found_txt.text = String(counter) + "/" + String(totalWords) + "correct";

     //This adds the correct word into the mcCheckArray.

     //This removes the correct word from wordsMcArray and the strArray.;

     //Removes the movie clip blur filter.
     mcCheckArray[mcCheckArray.length - 1].filters = [];

     //This clear the text field after a half second delay
     setTimeout(function(){ input_txt.text = ""; },500);

Step 5

In the document class add the name: ‘BlurGuess’ then export the movie Ctrl + Enter. You should now have a blur guess game in Actionscript 3.

You can download the source files here.

Update: Blur guess game part 2


sivareddy madireddy 8 August 2012 at 19:16  

I would like to know, if you have any tutorial for shall game in as3/as2. I appreciate your help.


iliketo 9 August 2012 at 11:39  


Please clarify what you mean by 'Shall game'?

Ega Setya Putra 16 August 2012 at 00:46  

I did exactly like you say but It won't work...

iliketo 16 August 2012 at 11:22  


Please read the steps carefully. I assume you have copied and pasted my code without actually understanding the code and reading through the tutorial.

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP