Flash Tutorial: Creating Random Characters

Home • Members Tutorials Forum iSnapChat Contact Us 

 


Flash Tutorials

   

Flash Tutorial - The Matrix Special Effects

 

Free Flash Tutorial


Step 2    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10     Next   >>      

 

Step Two: Creating Random Characters

In this example I will create a single Movie Clip that will generate random characters generated with ActionScript.

Note: If you did not want random characters but wanted a specific set of characters like: A, B & C you would create three Movie Clips each with one of the specified letters. You would then leave out the ActionScript that generates the random characters as described at the end of this step.

  1. Create a new Movie Clip Symbol: Insert > New Symbol (Ctrl + F8)
  2. Name the Movie Clip as: Characters
  3. Click: OK

  4. Select the Text Tool:
  5. If the Property Inspector is closed, open it: Window Properties > Properties (Ctrl F3)
  6. Select: Dynamic Text
  7. Select a standard type face such as: Verdana
  8. Set the Font size to: 12
  9. Set the color to green: 00CC00
  10. For style select: Bold
  11. For paragraph style select: Align Centre
  12. Type a single letter in the center of the Stage: A
  13. Note: In fact it is not necessary to type anything in the text box as random letters will be assigned via the ActionScript. I just find text boxes are easier to manage if they have something typed in them. The letter makes it easier to see what you are doing.

  14. In the Properties Inspector give the Text Box the Variable Name (Var): myLetter
  15. The text is set to Dynamic Text and has a Variable Name (not an Instance Name):


    Your Property Inspector should look similar to this.

  16. Return to the Selection Tool:
  17. If the Info Panel is closed, open it: Window > Info (Ctrl I)
  18. With your Text Box still selected set the registration to: Center
  19. Set the X & Y Both to Zero: 0
  20. Your Text Box should now be dead centre of the Stage:

  21. If the Timeline is not visible go to: Window > Timeline (Ctrl+Alt+T)
  22. In the Timeline select: Frame 1
  23. If the Actions Panel is closed, open it: Window > Actions (F9)
  24. If Script Assist is on, Switch it off:

    Note: With Script Assist on you cannot type in the Actions Panel. If you want to learn more about Script Assist see the tutorial on the Actions Panel

  25. Type (or copy & paste) the following actions:
  26. x = random (255);
    this.myLetter = chr (x) ;


The ActionScript Explained: The random(255) function will generate a number between 0 and 255 in a random order. The chr(x) is used to convert the number into the corresponding ASCII character (letters, numbers & symbols). This random generation of characters is what then sent to the text box called letter which is what you just created.

         

Step 2    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10     Next   >>      


51199 visitors to this page since 11 May 07 •

Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.