all groups > flash actionscript > february 2007 >
You're in the

flash actionscript

group:

Menu to Fade In/Out New Background Images and Text



Menu to Fade In/Out New Background Images and Text Kesey16
2/2/2007 11:25:31 PM
flash actionscript: I'm trying to create a navigation menu to fade background images in and out
based upon what the user clicks.

So, for example, I have:

Contact
About
Portfolio

The stage when the user clicks contact has one background, and then when they
click about, I want that background to fade out while the background fades in.
My problem is, you don't know which order the ppt will choose to navigate the
site so you can't hardcode the background that needs to fade out.

Can anyone point me to some code for this? Or a tutorial which may be helpful?

Thanks in advance.
Re: Menu to Fade In/Out New Background Images and Text kglad
2/3/2007 5:00:04 PM
1. your backgrounds should all be movieclips.
2. you should assign a linkage id to each background movieclip
3. when a link is clicked use a variable to store the name of the (next)
background movieclip that will be faded-in (when the previous is faded-out).
4. start a loop that fades the current background when a button is clicked.
again use a variable to store a reference to the current background movieclip.
3.5 this usually comes after the above step but pertains to something you
should do before the above: clear the above loop before starting it.
5. when the above fade completes, assign the variable that contains the
current background movieclip to the next background movieclip and start the
fade-in of the next background movieclip.
6. terminate your loop when fade-in is complete.
Re: Menu to Fade In/Out New Background Images and Text pubchum
2/3/2007 5:40:49 PM
you need to learn how to use the LoadMovieClip Class. I am into loading and
fading external pics too and Had too much trouble trying to coordinate
everything with onEnterFrame / delete onEnterFrame / gotoAnd....

when working with objects (a hurdle in itself) you will find this stuff much
easier to handle. I can't remember the good tutorials, but there's a few out
there on google.
Re: Menu to Fade In/Out New Background Images and Text kglad
2/3/2007 6:20:36 PM
Re: Menu to Fade In/Out New Background Images and Text Kesey16
2/4/2007 1:33:57 PM
Thanks for pointing me in the right direction. I ended up ditching the fade
out, and just went with fading the backgrounds in. I used a single movieclip's
timeline to house each background fading in and then used action script to code
the buttons like so:

btnAbout.onRelease=function(){
currBackground="about";
_root.mcBackground.gotoAndPlay("aboutIn");
}

Now I have to figure out if I can use my variable currBackground with other
pieces of the animation. This way, I'll be able to change the color of the
about button for example to let the user know that they're on the about page.

Any thoughts? I'm not sure this was the best way to code it, but it sure
seemed like the easiest. I wasn't too sure how to go about using the loop.
Re: Menu to Fade In/Out New Background Images and Text kglad
2/4/2007 3:54:27 PM
if you want to code all the color changes in one location you can use the
watch() function to detect changes to currBackground and color the old value
the default (not viewed page) and color the new value the whatever to indicate
the viewed page.

or just add the code to each button.
Re: Menu to Fade In/Out New Background Images and Text Kesey16
2/4/2007 6:09:14 PM
Thanks.

Re: Menu to Fade In/Out New Background Images and Text kglad
2/4/2007 6:17:24 PM
the variable, as used above with no prefix, will be available within all the
other onRelase handlers that are defined on the same timeline.

if you prefix with _global, the variable will be available on all timelines in
the same _level.

if you prefix with var, the variable will only be defined locally in that
onRelease handler. (which would be of no use to you in this situation.)
AddThis Social Bookmark Button