First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Sportzguy933

Controlling Alpha with Actionscript

Create a new Flash document CTRL + N (Apple + N on a Mac). Create a simple rectangle or square. Select that rectangle or square that you made, and convert it to a symbol (Modify>Convert to Symbol... or F8). Make it a movie clip, and set its instance name to "myClip". We’ll take my first example, dimming the button. So, make 3 input text boxes with instances names of text1, text2 and text3. Make a new layer and put this actionscript on the first frame: if (text1.text && text2.text && text3.text != "") { myClip._alpha = 100; }else{ myClip._alpha = 40; } Then, make another keyframe (on the blank layer) and press F5 on the other layer (to keep the contents the same). Then, enter the same AS on the second keyframe: if (text1.text && text2.text && text3.text != "") { myClip._alpha = 100; }else{ myClip._alpha = 40; } This will make Flash continue to check to make sure the text boxes aren't filled. Once they all are, Flash will set the alpha of myClip to 100. You could also use a loop (do...while) statement on 1 frame to get the same result, but let's stick with the conditional for now. Now let's explain that script above: We told Flash that if all of the text boxes are NOT equal (!=) to blank (""), then set myClip's alpha to 100. Otherwise, myClip's alpha should be 40. As you can see, we controlled the MC's alpha by using this format: instanceName._alpha = NUMBER; //(semi-colon is considered good //practice, but is optional So, if the instance name of my symbol was redBox, and I wanted to set its alpha to 35, I would use this: redBox._alpha = 35; There are many other parameters you can set using this format, such as _length, _width, _x, _y, etc. We’ll look at another example of controlling Alpha with Actionscript on the next page.
» Level Basic

Added: 2007-03-29
Rating: 6.73 Votes: 11
(10 being the highest)
» Author
If you need any help, please feel free to email me:
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.