Question : Using MovieClips as buttons with minor problems

I am using MovieClips as buttons in my flash and have added OnRollOver, OnRollOut and OnRelease action script code to the movieclip timelines to control the playing of various frames at certain times.

The OnRelease code plays a portion of the movieclip timeline that enlarges the movieclip picture from small to large.

The OnRollOver code plays another portion of the movieclip timeline that changs the brightness of the small version of the pic from dull to bright.

The OnRollOut code plays yet another portion of the movieclips timeline that reverses the brightness from bright to dull.

at the end of each one of these timelines is a stop(); action.

The problem that happens is that if a user rolls over a pic, it changes the brightness just fine, when they click the OnRelease code enlarges the pic just fine, BUT if the user rolls out of the big picture, the image snaps back to it's small version.  It is supposed to do nothing and stay large and only a second click on the image should resize the image smaller then change it's small pictures brightness to dull.

Here is a link to the flash for you to see:

http://www.restaurantblu.com/dev

When at the site, click on the bottom left blue button (Pictures) then rollover and click on any picture then roll off the large picture to see what I am talking about.

If you need to see the .fla, let me know and I will make available for you.

Thanks for any help.

Answer : Using MovieClips as buttons with minor problems

Well, you can set a variable and some if/then statements to take care of that.

I'll give you two ways. One easier than the other, albeit more cumbersome.

First way. Add a property to your mc's by using addProperty or prototype.. (that's the more advanced way)

The rudimentary way, but easier to understand.
Set up variables for all your mc's

_global.mc1stat="small";
_global.mc2stat="small";
_global.mc3stat="small";

etc..

Change your onRelease code so it changes the value of the variable.

button1.onRelease = function(){
mc1stat="large";
makeItBig(); //fictitious function to enlarge images
}

Change your rollOut code.

button1.onRollout = function(){
if(mc1stat=="small"){
makeItDim();  //fictitious function to dim lights
}
}

Now, you can  use the same logic back on your Release code in order to reduce the size back to normal

button1.onRelease = function(){
if(mc1stat=="small"){
mc1stat="large";
makeItBig(); //fictitious function to enlarge images
}else{
mc1stat="small";
makeitSmall();
}
}

Im away from Flash at this point so I cannot check the code, but the logic is definitely there.

Good luck!

Montoya



Random Solutions  
 
programming4us programming4us