Search tutorials
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". Well 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. Well look at another example of controlling Alpha with Actionscript on the next page.| » Level Basic |
|
Added: 2007-03-29 Rating: 8 Votes: 9 |
| » Author |
| If you need any help, please feel free to email me: sportzguy955@gmail.com |
| » Download |
| Download the files used in this tutorial. |
| Download (30 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


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