My Flash Resource – New Ideas and News for Applying Flash to Complex Gaming Apps

Latest News and Developments

May 25, 2008

For Beginners: Flash Random Number Creation

by @ 5:55 pm. Filed under Flash Tutorials has a great “click by click” tutorial for beginners regarding how to generate random numbers. In the example provided on the website, a Flash button programmed by Action Script displays a random number between 1 and 10 in a predefined window space.

If you click the number button repeatedly, another random number appears.

Beginners will love this easy tutorial, which shows all the steps necessary to recreate the example .swf file offered by the authors.

Here are some code snippets from the tutorial:

Step …

5. If Script Assist is on, Switch it off:
6. Type (or copy and paste) the following code in the Actions Panel;
on (release) {
myDisplay = random (10) +1;

7. Test your Movie: Control > Test Movie (Ctrl Enter)

The ActionScript Explained:

on (release) {
When the user releases the Mouse button what is between the curly braces …

myDisplay = random (10) +1;
In this case the random function creates a random number that starts at 0 and ends on the 10th digit. Which is the number specified in the parentheses: (10). If you start your count from zero (instead of 1) then the 10th digit is 9 (not 10)! So to make it count form 1 to 10 I simply add one to the result. Hence the +1.

The curly brace ends the on (release) statement.

The next code snippet creates the non-repeating random number effect. This is slightly more complicated, but does come with a working example file:

The ActionScript attached to the button is as follows:

on (release) {

// Sets the number of digits in the random sequence:
var mySetting = 3;

// Creates a random number:
myNumber = random(mySetting)+1;

// Checks to see if it is repeating itself:
if (myNumber == myTemp) {
// If it is repeating it generates a new random number:
myNumber = random(mySetting)+1;
// Continues as above:
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
if (myNumber == myTemp) {
myNumber = random(mySetting)+1;
// Displays the random number:
myDisplay = myNumber;
// Resets the variable to the new random number:
myTemp = myNumber;

Finally, after you’ve come this far, the tutorial concludes with a practical application of Flash Randon Number creation: Subbing the random numbers for 10 different instances of “Hello” in different languages.

Very Cool – It’s all here: Click by Click Flash Random Numbers

May 20, 2008 Flash Tutorial: Applying Flash 8 Filters with Action Script

by @ 6:04 pm. Filed under Flash Industry News has produced a short and sweet Flash 8 tutorial for applying filters with the use of Action Script.

The tutorial is self rated as “intermediate” level. You should have some knowledge of the “arrays class” in AS so you can play around with the filters. Of course, basic knowledge of Action Script coding and its integration with Flash output is required as well.

The step-by-step tutorial walks you through the creation process, complete with screen captures of toolbar images and menu navigation.

The tutorial finishes with a bit of code, required to make your filter effects work:

var myBlur = new flash.filters.BlurFilter();
var myTempFilters:Array = circle_mc.filters;
circle_mc.filters = myTempFilters;

If you can understand the basic principles behind this sequence, you should have no problem with Oman3d’s tutorial – see this link:

Flash 8 Filters Using Action Script

« Previous PageNext Page »

My Flash Resource - A continually growing collection of tutorials, thoughts and interests of a Flash Animator and/or Developer.



New Feedburner Feed!

Feel free to syndicate.

Learning Material

Flash Resources:

Listed on BlogShares
  • Resources