First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
Search tutorials
Author: Matt Arenson | Website: http://www.wildinkgc.com

Using the _visible command to save space and time (so to speak)

Ok, so this tutorial may not actually save the universe, but it will save you space on the stage and time coding.

This tutorial assumes basic knowledge of movie clips, buttons, and actionscripting.

This tutorial is basically here to relay a trick using the _visible command in Flash that lets you use the same space on the stage for multiple objects in one frame. I am sure people are using this trick already, but I haven't seen a tutorial on it and i know that it would have helped me at least once. So, here goes..

Take a look at the Flash movie below:

This is basically a simple menu that when you click a button on the left, something appears on the right. The difference is that this menu is contained in one frame on the timeline, and does not load in any other movies. This saves you from copying buttons and editing script, as well as taking up frame space

Let's get started on the stage..

NEXT

The Stage:

start out by building your buttons on the left, as many as you like. When that is completed we begin to construct the content.

1. Make a new layer for every button. Keep the buttons on the layer they were created on. Name the new layers for the buttons they will correspond to (I.E. if the button is "home", name the layer that will have its content "home" as well).

2. On each of the new layers, create the content that will be shown when that button is clicked. Keep in mind that all of the content on each layer will eventually be put into a movie clip.

3. On each content layer, select everything on it and turn it into a symbol named after the button it corresponds to (home or home1 for the "home" button). Also, make sure to give your new symbol on each layer an instance name that that will correspond to the button it represents (homecontent for "home").

4. After you get all of your symbols made and named, move them all to the layer with the buttons. You can delete the other layers if you like. They will overlap each other and probably be unrecognizable, but that is ok.

And now, we'll make this mess work. On to the action scripting..

PREV NEXT

The Action Scripting:

Ok, so we effectively have made a mess, what now? Now we add the action scripting.

On the frame, add the following actions:

vis();
function vis(){
_root.one._visible=false;
_root.two._visible=false;
_root.three._visible=false;
_root.four._visible=false;
_root.five._visible=false;
}

Here's what it does:

vis(); calls the function with the name "vis" below:


function vis(){
_root.one._visible=false;
_root.two._visible=false;
_root.three._visible=false;
_root.four._visible=false;
_root.five._visible=false;
}

This function makes all of the content movie clips you created invisible. It calls each movie clip by its instance name and tells it to go invisible. When a movie clip is invisible, it acts just like it is on another frame altogether: no buttons work, no animations play.

Now, On each button add the following code:

on(release){
vis();
_root.one._visible=true;
}

These actions above are for the button that corresponds to the content movie clip with the instance name "one". These actions do a couple things:

1. It calls the "vis" function and makes everything invisible again (just in case this button is not the first one they push)

2. It tells the content movie clip "one" to become visible. This makes it seem as though the movie has changed frames, when it actually has not. Only the content in the movie clip "one" is visible. (The _visible command works like this: false = invisible, true = visible)

Change "_root.one" to each movie clip instance name for each corresponding button.

Keep in mind that this can be triggered from a frame, another movie, a movie clip, etc..

That's it!! Test your movie.

If it does not work, make sure that the "vis" function is on the main timeline and that you have given all content movie clips instance names. Also check that all the names in the action scripting correspond to the actual movie clips' instance names.

Good Luck! I hope you find this little trick as useful as I have!!

PREV

» Level Intermediate

Added: 2005-02-10
Rating: 8.06 Votes: 31
(10 being the highest)
» Author
www.wildinkgc.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: 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.