First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
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: 8 Votes: 9
(10 being the highest)
» Author
If you need any help, please feel free to email me: sportzguy955@gmail.com
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • 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: S.Saipriya
» Title: Flash Fire Effect
» Description: This tutorial explains about how to create Fire Effect in Flash of Actionscript 2.0.I hope this tutorial helps you!
Featured Sound Loops
Image for equalize

Audio Player

» Author: Aidan Crouzet-Pascal
» Title: Falling Star
» Description: This loop is a cool sounding, E minor loop.
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: Brandan Paulin
» Description: Epic sounding loop with Brass, Percussion, Strings and Winds. This is actually part of a Loop Pack called the Coming where you can download the rest of the loops that go with it FREE from my website.