* UPDATE: New CSS / JavaScript version of Random Number Generator, check THIS POST.


There was a few posts on my older blog in form of tutorial on how to create random number generator with blur effect. I'm near bandwidth limit, so no live example, but click on preview image to download files.


Flash random number generator


here is required code

   
 // author: FLANTURE http://flanture.blogspot.com  
 // date: 24 Jan 2009  
   
 import flash.filters.BlurFilter;  
   
 // function for roll_mc movie clip onPress action. If timer has not started,  
 // that means there is no action in progress, so we can start one.  
   
 roll_mc.onPress = function() {  
  if (!timerStarted) {  
  var filter:BlurFilter = new BlurFilter(60, 120, 1);  
  var filterArray:Array = new Array();  
  filterArray.push(filter);  
  num1_txt.filters = filterArray;  
  var newNumber1 = Math.floor(Math.random()*10);  
  num1_txt.text = newNumber1;  
  num2_txt.filters = filterArray;  
  var newNumber2:Number = Math.floor(Math.random()*10);  
  num2_txt.text = newNumber2;  
  num3_txt.filters = filterArray;  
  var newNumber3:Number = Math.floor(Math.random()*10);  
  num3_txt.text = newNumber3;  
  timerStarted = true;  
  }  
 }  
   
 // functions for restoring blur effect  
   
 function restoreBlur1() {  
  num1_txt.filters = new Array(filter);  
 }  
 function restoreBlur2() {  
  num2_txt.filters = new Array(filter);  
 }  
 function restoreBlur3() {  
  var filter:BlurFilter = this.filters[0];  
  filter.blurY = 0;  
  filter.blurX = 0;  
  num3_txt.filters = new Array(filter);   
 }  
   
 // next function controls when blur should stop and numbers should display.  
   
 onEnterFrame = function () {  
  if (timerStarted) {  
  if (counter < thirdDigitStop) {  
   counter += 1;  
   if (counter == firstDigitStop) {  
   restoreBlur3();  
   }  
   if (counter == secondDigitStop) {  
   restoreBlur2();  
   }  
  } else {  
   timerStarted = false;  
   counter = 0;  
   restoreBlur1();  
  }  
  }  
 }  
   
 // you can change firstDigitStop and other variables to suit your needs.  
 // numbers represent frames, not seconds.  
   
 onLoad = function () {  
  timerStarted = false;  
  counter = 0;  
  firstDigitStop = 8;  
  secondDigitStop = 16;  
  thirdDigitStop = 24;  
 }  
   


This example can be used as slot machine simulation or anything similar you can think of.

*_*