Recipe 11.14. Changing Movie Clip VisibilityProblemYou want to make a movie clip invisible or visible. SolutionSet the _visible property. ProblemMovie clip instances default to being visible. However, you can also programmatically toggle the visibility of a movie clip using the _visible property. You may be wondering why you would want to set the _visible property to false rather than simply setting the _alpha property to 0. There is a very important distinction to make between these two properties. When you set the _alpha property to 0, the movie clip may appear invisible, but it will still respond to mouse events, and can otherwise receive focus in the movie. In the event that you want to use a movie clip as an invisible button, this is exactly what you want. However, if you want to temporarily hide a movie clip from the user such that it does not even respond to mouse events, you should set the _visible property to false. mClip._visible = false; You can also reinstate visibility by setting the _visible property to true: mClip._visible = true; A perfect example of how you might use the _visible property is to hide a button until some other user activity (or perhaps a server response) has occurred. One such scenario might be that you might want to hide the Continue button from the user until they have completed all the requested tasks for the given "page." On the frame on which the page is created in your Flash movie, you can initialize the button to be invisible: btContinue._visible = false; Then, after all the tasks have been completed, you can make the button visible: btContinue._visible = true; The _visible property is a very important property as you begin to move from basic Flash movie architecture to more advanced architectures. You can actually create multiple "pages" all within a single keyframe, and by using the _visible property you can switch between them. This has many advantages, including:
You can see many more examples of how to use _visible to perform these kinds of advanced ActionScript tasks in the ActionScript Cookbook (O'Reilly). |
Tripod >> 3pod Tips & Learning and manuals for educations