mc buttons - functions  
Author Message
fire orchid





PostPosted: 2006-11-5 12:28:19 Top

flash-actionscript, mc buttons - functions Hi there

I have a bit of a sticky one I think - but hopefully you will be able to see
something in my code that I am missing...

I have a menu that I am using with movie clips as buttons, and all of the
functions in one frame on the first frame of the movie.

Each "button" is not a button at all, but a movie clip, with the correct
instance name, as seen in the code below (eg craftBUTTON) and they are all set
at alpha 80%

It is currently loaded as is here :

http://www.fili.com.au/buttons-play.htm

You will see straight away what the problem is - most of the buttons seem to
work ok, but then the second one keeps decreasing in alpha each time it is
rolloed over, and does not increase when the mouse rolls out.

Also, the third button increases in alpha and stays at 100%

The code on the first frame is attached (I hope!)

The next trouble I am having comes when I want to do an onRelease function,
and the timeline does not seem to want to stop at the stop action I have on
that frame - but we'll worry about that when I get this first bit fixed up!

I am hoping that it is just something I am missing in the code, or maybe there
is conflict and I need to separate the functions out..?

Thankyou!

stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
craftBUTTON.onRollOver = function() {
craftBUTTON._alpha +=20;
craftBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(craftBUTTON,
"_xscale",Elastic.easeOut,craftBUTTON._xscale,110,2,true);
new Tween(craftBUTTON,
"_yscale",Elastic.easeOut,craftBUTTON._yscale,110,2,true);
}
craftBUTTON.onRollOut = function() {
craftBUTTON._alpha -=20;
new Tween(craftBUTTON,
"_xscale",Elastic.easeOut,craftBUTTON._xscale,100,2,true);
new Tween(craftBUTTON,
"_yscale",Elastic.easeOut,craftBUTTON._yscale,100,2,true);
}
storyBUTTON.onRollOver = function() {
storyBUTTON._alpha +=20;
storyBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(storyBUTTON,
"_xscale",Elastic.easeOut,storyBUTTON._xscale,110,2,true);
new Tween(storyBUTTON,
"_yscale",Elastic.easeOut,storyBUTTON._yscale,110,2,true);
}
storyBUTTON.onRollOut = function() {
storyBUTTON._alpha -=20;
new Tween(storyBUTTON,
"_xscale",Elastic.easeOut,storyBUTTON._xscale,100,2,true);
new Tween(storyBUTTON,
"_yscale",Elastic.easeOut,storyBUTTON._yscale,100,2,true);
}
collectBUTTON.onRollOver = function() {
collectBUTTON._alpha +=20;
collectBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(collectBUTTON,
"_xscale",Elastic.easeOut,collectBUTTON._xscale,110,2,true);
new Tween(collectBUTTON,
"_yscale",Elastic.easeOut,collectBUTTON._yscale,110,2,true);
}
collectBUTTON.onRollOut = function() {
storyBUTTON._alpha -=20;
new Tween(collectBUTTON,
"_xscale",Elastic.easeOut,collectBUTTON._xscale,100,2,true);
new Tween(collectBUTTON,
"_yscale",Elastic.easeOut,collectBUTTON._yscale,100,2,true);
}
engageBUTTON.onRollOver = function() {
engageBUTTON._alpha +=20;
engageBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(engageBUTTON,
"_xscale",Elastic.easeOut,engageBUTTON._xscale,110,2,true);
new Tween(engageBUTTON,
"_yscale",Elastic.easeOut,engageBUTTON._yscale,110,2,true);
}
engageBUTTON.onRollOut = function() {
engageBUTTON._alpha -=20;
new Tween(engageBUTTON,
"_xscale",Elastic.easeOut,engageBUTTON._xscale,100,2,true);
new Tween(engageBUTTON,
"_yscale",Elastic.easeOut,engageBUTTON._yscale,100,2,true);
}
mediaBUTTON.onRollOver = function() {
mediaBUTTON._alpha +=20;
mediaBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(mediaBUTTON,
"_xscale",Elastic.easeOut,mediaBUTTON._xscale,110,2,true);
new Tween(mediaBUTTON,
"_yscale",Elastic.easeOut,mediaBUTTON._yscale,110,2,true);
}
mediaBUTTON.onRollOut = function() {
mediaBUTTON._alpha -=20;
new Tween(mediaBUTTON,
"_xscale",Elastic.easeOut,mediaBUTTON._xscale,100,2,true);
new Tween(mediaBUTTON,
"_yscale",Elastic.easeOut,mediaBUTTON._yscale,100,2,true);
}
showBUTTON.onRollOver = function() {
showBUTTON._alpha +=20;
showBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(showBUTTON,
"_xscale",Elastic.easeOut,showBUTTON._xscale,110,2,true);
new Tween(showBUTTON,
"_yscale",Elastic.easeOut,showBUTTON._yscale,110,2,true);
}
showBUTTON.onRollOut = function() {
showBUTTON._alpha -=20;
new Tween(showBUTTON,
"_xscale",Elastic.easeOut,showBUTTON._xscale,100,2,true);
new Tween(showBUTTON,
"_yscale",Elastic.easeOut,showBUTTON._yscale,100,2,true);
}
memberBUTTON.onRollOver = function() {
memberBUTTON._alpha +=20;
memberBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(memberBUTTON,
"_xscale",Elastic.easeOut,memberBUTTON._xscale,110,2,true);
new Tween(memberBUTTON,
"_yscale",Elastic.easeOut,memberBUTTON._yscale,110,2,true);
}
memberBUTTON.onRollOut = function() {
memberBUTTON._alpha -=20;
new Tween(memberBUTTON,
"_xscale",Elastic.easeOut,memberBUTTON._xscale,100,2,true);
new Tween(memberBUTTON,
"_yscale",Elastic.easeOut,memberBUTTON._yscale,100,2,true);
}
contactBUTTON.onRollOver = function() {
contactBUTTON._alpha +=20;
contactBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(contactBUTTON,
"_xscale",Elastic.easeOut,contactBUTTON._xscale,110,2,true);
new Tween(contactBUTTON,
"_yscale",Elastic.easeOut,contactBUTTON._yscale,110,2,true);
}
contactBUTTON.onRollOut = function() {
contactBUTTON._alpha -=20;
new Tween(contactBUTTON,
"_xscale",Elastic.easeOut,contactBUTTON._xscale,100,2,true);
new Tween(contactBUTTON,
"_yscale",Elastic.easeOut,contactBUTTON._yscale,100,2,true);
}

 
kglad





PostPosted: 2006-11-5 12:51:00 Top

flash-actionscript >> mc buttons - functions your collectionButton has incorrect rollOut code.
 
fire orchid





PostPosted: 2006-11-5 13:02:00 Top

flash-actionscript >> mc buttons - functions Oh my god - I have been looking at this for hours... THANKYOU!!

Now for the next problem....

I have now added the following function to take you to the craftsmanship page.

The only difference on that page is that I have removed the "craftsmanship"
button, and replaced it with a static text title - it seems to go there, but
does not stop (I have a stop action on the craftsmanship frame)


craftBUTTON.onRelease = function(){
gotoAndPlay ("craftsmanship");
}

 
 
kglad





PostPosted: 2006-11-5 13:14:00 Top

flash-actionscript >> mc buttons - functions copy and paste the code from your "crafsmanship" frame.
 
 
fire orchid





PostPosted: 2006-11-5 13:18:00 Top

flash-actionscript >> mc buttons - functions it just has a stop action a few frames along, as I want to do an animation when it goes to that page

ie:

stop();

do I need to repeat all the other functions again on each page it goes to?

 
 
kglad





PostPosted: 2006-11-5 13:25:00 Top

flash-actionscript >> mc buttons - functions your craftButton will no longer function if your timeline goes to a frame where
the craftButton no longer exists. even if you return to a frame where it does
exist the code you defined for it will be lost unless it's re-executed.

 
 
fire orchid





PostPosted: 2006-11-5 13:29:00 Top

flash-actionscript >> mc buttons - functions Ok - so now I know that each time I want to re-execute an mcButton, I have to
recall the function - yeah?

The timeline is still not stopping, or at least, it does not appear to be,
because the craftBUTTON is still there somehow...?

See the code now:

import mx.transitions.Tween;
import mx.transitions.easing.*;
storyBUTTON.onRollOver = function() {
storyBUTTON._alpha +=20;
storyBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(storyBUTTON,
"_xscale",Elastic.easeOut,storyBUTTON._xscale,110,2,true);
new Tween(storyBUTTON,
"_yscale",Elastic.easeOut,storyBUTTON._yscale,110,2,true);
}
storyBUTTON.onRollOut = function() {
storyBUTTON._alpha -=20;
new Tween(storyBUTTON,
"_xscale",Elastic.easeOut,storyBUTTON._xscale,100,2,true);
new Tween(storyBUTTON,
"_yscale",Elastic.easeOut,storyBUTTON._yscale,100,2,true);
}
collectBUTTON.onRollOver = function() {
collectBUTTON._alpha +=20;
collectBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(collectBUTTON,
"_xscale",Elastic.easeOut,collectBUTTON._xscale,110,2,true);
new Tween(collectBUTTON,
"_yscale",Elastic.easeOut,collectBUTTON._yscale,110,2,true);
}
collectBUTTON.onRollOut = function() {
collectBUTTON._alpha -=20;
new Tween(collectBUTTON,
"_xscale",Elastic.easeOut,collectBUTTON._xscale,100,2,true);
new Tween(collectBUTTON,
"_yscale",Elastic.easeOut,collectBUTTON._yscale,100,2,true);
}
engageBUTTON.onRollOver = function() {
engageBUTTON._alpha +=20;
engageBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(engageBUTTON,
"_xscale",Elastic.easeOut,engageBUTTON._xscale,110,2,true);
new Tween(engageBUTTON,
"_yscale",Elastic.easeOut,engageBUTTON._yscale,110,2,true);
}
engageBUTTON.onRollOut = function() {
engageBUTTON._alpha -=20;
new Tween(engageBUTTON,
"_xscale",Elastic.easeOut,engageBUTTON._xscale,100,2,true);
new Tween(engageBUTTON,
"_yscale",Elastic.easeOut,engageBUTTON._yscale,100,2,true);
}
mediaBUTTON.onRollOver = function() {
mediaBUTTON._alpha +=20;
mediaBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(mediaBUTTON,
"_xscale",Elastic.easeOut,mediaBUTTON._xscale,110,2,true);
new Tween(mediaBUTTON,
"_yscale",Elastic.easeOut,mediaBUTTON._yscale,110,2,true);
}
mediaBUTTON.onRollOut = function() {
mediaBUTTON._alpha -=20;
new Tween(mediaBUTTON,
"_xscale",Elastic.easeOut,mediaBUTTON._xscale,100,2,true);
new Tween(mediaBUTTON,
"_yscale",Elastic.easeOut,mediaBUTTON._yscale,100,2,true);
}
showBUTTON.onRollOver = function() {
showBUTTON._alpha +=20;
showBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(showBUTTON,
"_xscale",Elastic.easeOut,showBUTTON._xscale,110,2,true);
new Tween(showBUTTON,
"_yscale",Elastic.easeOut,showBUTTON._yscale,110,2,true);
}
showBUTTON.onRollOut = function() {
showBUTTON._alpha -=20;
new Tween(showBUTTON,
"_xscale",Elastic.easeOut,showBUTTON._xscale,100,2,true);
new Tween(showBUTTON,
"_yscale",Elastic.easeOut,showBUTTON._yscale,100,2,true);
}
memberBUTTON.onRollOver = function() {
memberBUTTON._alpha +=20;
memberBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(memberBUTTON,
"_xscale",Elastic.easeOut,memberBUTTON._xscale,110,2,true);
new Tween(memberBUTTON,
"_yscale",Elastic.easeOut,memberBUTTON._yscale,110,2,true);
}
memberBUTTON.onRollOut = function() {
memberBUTTON._alpha -=20;
new Tween(memberBUTTON,
"_xscale",Elastic.easeOut,memberBUTTON._xscale,100,2,true);
new Tween(memberBUTTON,
"_yscale",Elastic.easeOut,memberBUTTON._yscale,100,2,true);
}
contactBUTTON.onRollOver = function() {
contactBUTTON._alpha +=20;
contactBUTTON.swapDepths(this.getNextHighestDepth());
new Tween(contactBUTTON,
"_xscale",Elastic.easeOut,contactBUTTON._xscale,110,2,true);
new Tween(contactBUTTON,
"_yscale",Elastic.easeOut,contactBUTTON._yscale,110,2,true);
}
contactBUTTON.onRollOut = function() {
contactBUTTON._alpha -=20;
new Tween(contactBUTTON,
"_xscale",Elastic.easeOut,contactBUTTON._xscale,100,2,true);
new Tween(contactBUTTON,
"_yscale",Elastic.easeOut,contactBUTTON._yscale,100,2,true);
}
stop();

 
 
fire orchid





PostPosted: 2006-11-5 14:17:00 Top

flash-actionscript >> mc buttons - functions :frown;

agghh - this is so frustrating - doesn't matter what I try, it doesn't work :(

 
 
kglad





PostPosted: 2006-11-5 15:13:00 Top

flash-actionscript >> mc buttons - functions your going to a frame on your main timeline that is a keyframe and doesn't have
the craftButton on-stage and the craftButton is not created with actionscript?
if yes to both post a link to your fla and specify the location of the problems.

 
 
fire orchid





PostPosted: 2006-11-5 15:21:00 Top

flash-actionscript >> mc buttons - functions Hello again!

Boy am I glad to see you - how dare you have a life ;)

Thankyou so much for your excellent help so far! The fla can be downloaded
from here - yes to both of those questions.

http://www.fili.com.au/new01.fla

The main thing I am trying to do at this stage is get the time line to
onRelease gotoAndPlay ("craftsmanship"), which it kind of does, because you can
see the static title, but then when you rollover anything else it somehow moves
to somewhere else on the timeline...

Weird - I am not explaining it well, but you will see hopefully when you see
the fla

THANKYOU!

 
 
fire orchid





PostPosted: 2006-11-5 21:41:00 Top

flash-actionscript >> mc buttons - functions Have been playing around - still no joy :(

Have uploaded a newer fla here:

http://www.fili.com.au/new03.fla

The problem swf can be viewed here:

http://www.fili.com.au/buttons-play.htm

There is another movie loading into the collections section which is
incomplete, and I am having some troubles with that too - I want it to scroll
only on RollOver, and as the mouse moves more up it scrolls faster or down it
scrolls down etc... But that is another problem which I am sure I will sort out
in the next little while...

Thanks to anyone who can help out! I'm off to bed...

Mandi
x

 
 
kglad





PostPosted: 2006-11-6 0:08:00 Top

flash-actionscript >> mc buttons - functions when you use swapDepths() you're movieclip is attached to the timeline via
actionscript and must be removed using removeMovieClip().

but in your situation i can't see any reason to use swapDepths(). eliminate
that part of the code you should have less trouble.

 
 
fire orchid





PostPosted: 2006-11-6 5:34:00 Top

flash-actionscript >> mc buttons - functions Hi again kglad,

Thankyou! That seems to have helped - and in fact there was a biut of messy
coding, and I discovered that I had left out a few semi-colons... :\

The buttons are looking a lot better now, and doing what they are meant to do,
except it seems as if they are still losing some alpha each time you rollover
and rollout, until you click on a new one, then they are reset to the 80%.

Can you think of a way to rectify this?

I have reloaded the fla too - can be found here --

http://www.fili.com.au/new03.fla

and the swf is still at the same url

http://www.fili.com.au/buttons-play.htm

Thanks once again! You have saved me a lot of heart ache so far!

:)

 
 
kglad





PostPosted: 2006-11-6 14:22:00 Top

flash-actionscript >> mc buttons - functions because flash doesn't store movieclip alphas as an integer, you may run into
problems increasing and decreasing your alpha by 20 because of repeated
round-offs.

to remedy, you can either set the alpha to 80 and 100 or you can use a
variable to increment and decrement by 20 (flash won't round a variable) and
then set your button movieclip's _alpha equal to that variable.

 
 
fire orchid





PostPosted: 2006-11-7 5:46:00 Top

flash-actionscript >> mc buttons - functions Such a simple remedy! That is wonderful - thankyou so much - I think I will start a new thread for the next problem...

Thanks so much for your help!
 
 
kglad





PostPosted: 2006-11-7 13:16:00 Top

flash-actionscript >> mc buttons - functions you're welcome.