PDA

View Full Version : Menu Flow


Michelsen
05-04-2001, 08:34 PM
I'm new to Flash programming and have started to work on a company business card project for educational purposes. The problem I'm having is coming up with a clean way to bring up arbitrary movies clips from a menu.

Is there an accepted way of doing this? Things I've tinkered with are:

(1) Movie clips on specific frames with each frame having a stop action to hold the playing to that clip and a button sending it to that frame. This seemed messy but it worked unless you hit a button to send you to a specific frame and you were already there.

(2) Movie clips are initially invisible and they are all stacked on top of each other in the same frames. Buttons turn the specific movie visible and turn all the previously visible ones off. I haven't tried this method yet, but I'm not convinced this is clean either, and I haven't figured out how to initially set all the movies to invisible (i.e. actionscript on first frame or some neat initial properties option I haven't found yet).

I have valiantly searched for a good example, and I haven't found one with out so much overhead in it that I had to get the aspirin bottle out.

Any help would be greatly appreciated. I'm really interested in what the "average bear" is doing.

Erik Michelsen

Jesse
05-05-2001, 10:29 AM
I would use option 2, it's clean.
Give your graphics (movie clips) instance names which are sequential, like "graphic1", "graphic2", etc.

Then use a loop and a function. So on the first frame of you movie have this function:

function hideThem (button) {
for (x=1; x<5; x++) {
if (x != button) {
_root["graphic"+x]._visible = false;
} else {
_root["graphic"+x]._visible = true;
}
}
}
hideThem()

This function takes one argument; the number of the graphic you want to display, and hides all graphics but that one. Given no argument it hides all graphics so on the first frame you run it with no arguments:

_root.hideThem()

This will make all your graphics invisible. Then make your buttons have code like this:

on (release) {
hideThem(Z);
}

Where 'Z' is a number indicating which graphic you wish to show. All other graphics will be hidden

Cheers

Jesse

Michelsen
05-08-2001, 02:48 PM
Thanks Jesse.

I have to admit, I'm still having problems. It sounds so easy when you explain it, but I can't seem to get it to work. I have put the function on frame 1, but it doesn't hide the movie clips (mc1 and mc2). If you are interested, you can download the fla at http://asip.tinker.af.mil/for-testing/emichel/Demo.fla and see my broken stuff yourself ;) I'm pulling my hair out.

Best wishes.

Erik

Michelsen
05-08-2001, 03:55 PM
Ah, okay, I figured it out. Lesson learned... instance name is not equal to movie clip name.

Erik

Jesse
05-09-2001, 05:00 AM
hehe :)

There's a tutorial on instance if you need more info

Cheers

Jesse