View Full Version : Buttons in Flash

03-08-2007, 08:11 AM

Ok, my newest hangup

What is the simplest way to transition betwen pages of a webpage in flash?
I'm creating a flash based website with buttons etc...

I would like there to be transitions between the pages of the webpage. I've animated in and out states for these animations within each of the pages. If I were to play the "home" movieclip from start to finish the effect would be transition in >> content >> transition out.

Now, anytime I click on another button from the home page, I'd like the transition out of the home to play followed by the transition in of whatever page's link was clicked on. This wouldn't be hard if i were talking of one or two buttons. But I have quite a few.

I could create seperate actionscript for each link on each page to get the effect I suppose, but i was wondering if there was a simpler way to do it, using some sort of "if" statement perhaps.

In short, the actionscript should do the following.

when a link is clicked:

1. Determine which movie clip is on the screen (each of my pages is within a mc called home, bio, portfolio etc...) and play its "out" state (labeled such in a labels layer)
2. Determine which link has been clicked and play its "in" state (in states start at frame 1 so a simple gotoandplay statement will do)

Using Flash 8

03-08-2007, 02:39 PM
One way is to set an invisible variable in each of the pages "content" section. So where you have in>>content>>out, you should have a stop(); action on the content section of each.

add this below the stop();

var content:Number = 1;

just increment it for each (Number = 2, Number = 3, etc..)

then on the button have something like:

if (_root.content == 1){
_root.nameOf_MC with 1 as content#.gotoAndPlay("outframeLable");
if (_root.nameOf_MC with 1 as content#._currentframe == ("endframe#"){
_root.content = 0;
_root.nameOf_MC with 2 as content#.gotoAndPlay("frameNumber_of_content");
else if (_root.content == 2){
_root.nameOf_MC with 2 as content#.gotoAndPlay("outframeLable");
if (_root.nameOf_MC with 2 as content#._currentframe == ("endframe#"){
_root.content = 0;
_root.nameOf_MC with 3 as content#.gotoAndPlay("frameNumber_of_content");
//continue for all buttons

This isn't perfect, but I have only been awake for 20 minutes :D It should give you the idea though.

03-08-2007, 05:41 PM
Wow...you're dedicated blizzard. Helping me out right after you get up, I really appreciate that.

I was hoping that maybe you could give me an example of how this might work. I'm having some issues in implementing it.

I'm attaching a basic mock-up of my site so you don't have to create anything from scratch.

Thanks a lot.


03-08-2007, 10:13 PM
After looking at your movie, I made a few changes to my original post.

You were close, and had the right idea. We needed to basically add 3 actions to one button.

It is live and working here (attached below) Take a look at the actions panel on frame 1, the actions on each button, AND the actions on the last frame (21) of EACH p1, p2, etc MC. :D


03-09-2007, 07:02 AM
Thank you Blizzard.

You are my hero!

A follow-up question:

How do i tweak it if the 1st frame w/ the navigation buttons is not the first frame of the flash document.
I.E. what if the entire animation started on say, frame 5 instead of frame 1.

it seems not to work in this instance...

03-11-2007, 10:53 PM
Have you been able to figure this one out Blizzard?

I'm very curious to know the fix.

03-12-2007, 10:58 PM
Oh, yes, sorry, I got busy with my personal sites :)

It's an easy fix really. Set your movie up how you need, put everything where you want it. Let's say you are going to have the buttons and what not stat at frame 5, instead of frame 1.

on the actual page buttons find this line:

} else if (_root._currentframe == "1") {

change the "1" to "5" then sequentially for each of the other "else if's" on that button. Then change the same lines accordingly for the other 5 buttons.

so for a full example, the page1 button would have this code:

on (release) {
if (_root._cont == 0) {
} else if (_root._currentframe == "5") {
_root.cont = 1;
} else if (_root._currentframe == "6") {
_root.cont = 1;
} else if (_root._currentframe == "7") {
_root.cont = 1;
} else if (_root._currentframe == "8") {
_root.cont = 1;
} else if (_root._currentframe == "9") {
_root.cont = 1;
} else if (_root._currentframe == "10") {
_root.cont = 1;

03-13-2007, 04:56 AM
thanks Blizzard!

As always, you've saved me!

03-13-2007, 01:05 PM
You are welcome :D

Glad it all works for you