Mc buttons need code to navigate using them

Hi,

I have three movie clips that I am using as buttons.

Their instances in the movie are Espanol_btn, Francais_btn and Deutsch_btn.

I have added script to control the rollover and press/release states of the buttons, and now need to get the script to recognise which of the three buttons was pressed, store that result in the variable called [COLOR=Blue]lang [COLOR=Black](The posibilities are Espanol, Francais or Deutsch), and depending on what the variable [COLOR=Blue]land [/COLOR]is, do different things. The script is below.

ActionScript Code:
[LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];

[COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].*;
[COLOR=#000000]var[/COLOR] lang:[COLOR=#0000FF]String[/COLOR];
[COLOR=#000000]var[/COLOR] year:[COLOR=#0000FF]Number[/COLOR] =[COLOR=#000080]0[/COLOR];
[COLOR=#000000]var[/COLOR] unit:[COLOR=#0000FF]Number[/COLOR] =[COLOR=#000080]0[/COLOR];
[COLOR=#000000]var[/COLOR] section:[COLOR=#0000FF]Number[/COLOR] =[COLOR=#000080]0[/COLOR];

[COLOR=#808080]//===============================LOGO ANIMATES ONSTAGE=========================================[/COLOR]
[COLOR=#808080]// move top logo into position[/COLOR]
[COLOR=#000000]var[/COLOR] yPosT:Tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]logoTop, [COLOR=#FF0000]"_y"[/COLOR], Elastic.[COLOR=#000080]easeInOut[/COLOR], -[COLOR=#000080]38[/COLOR].[COLOR=#000080]5[/COLOR], -[COLOR=#000080]0[/COLOR].[COLOR=#000080]3[/COLOR], [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#808080]//=====================LANGUAGE BUTTONS - ROLLOVER ANIMATION FUNCTIONS=========================================[/COLOR]
[COLOR=#808080]// function to grow lang_btns on rollover[/COLOR]
[COLOR=#000000]function[/COLOR] growCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] < [COLOR=#000080]110[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] += [COLOR=#000080]5[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_yscale[/COLOR] += [COLOR=#000080]5[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000]null[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]// function to grow lang_btns continuously on rollover[/COLOR]
[COLOR=#000000]function[/COLOR] growOverTimeCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = grow;
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]// function to shrink lang_btns on rollout[/COLOR]
[COLOR=#000000]function[/COLOR] shrinkCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] > [COLOR=#000080]100[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] -= [COLOR=#000080]5[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_yscale[/COLOR] -= [COLOR=#000080]5[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000]null[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]// function to shrink lang_btns incrementally on rollout[/COLOR]
[COLOR=#000000]function[/COLOR] shrinkOverTimeCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = shrink;
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]//=====================LANGUAGE BUTTONS - RELEASE OUTSIDE FUNCTION=========================================[/COLOR]
[COLOR=#808080]*// function to release lang_btns & call shrink() function on onReleaseOutside *[/COLOR]
[COLOR=#000000]function[/COLOR] unpressOutsideCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] > [COLOR=#000080]100[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_xscale[/COLOR] -= [COLOR=#000080]2[/COLOR].[COLOR=#000080]5[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_yscale[/COLOR] -= [COLOR=#000080]2[/COLOR].[COLOR=#000080]5[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] -[COLOR=#000080]5[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] -[COLOR=#000080]5[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000]null[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]//=====================LANGUAGE BUTTONS - PRESS/RELEASE FUNCTIONS=========================================[/COLOR]
[COLOR=#808080]// function to press lang_btns onPress[/COLOR]
[COLOR=#000000]function[/COLOR] depressCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] +[COLOR=#000080]5[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] +[COLOR=#000080]5[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]// function to release lang_btns onRelease[/COLOR]
[COLOR=#000000]function[/COLOR] unpressCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] -[COLOR=#000080]5[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] -[COLOR=#000080]5[/COLOR];
[COLOR=#808080]// run ‘navigate’ function[/COLOR]
navigateCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]//=====================LANGUAGE BUTTONS - NAVIGATION SCRIPT========================================[/COLOR]
[COLOR=#808080]// function to navigate to next level of buttons[/COLOR]
[COLOR=#000000]function[/COLOR] navigateCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]lang == [COLOR=#FF0000]“Espanol”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]_root[/COLOR].[COLOR=#0000FF]gotoAndStop[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]lang == [COLOR=#FF0000]“Francais”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]_root[/COLOR].[COLOR=#0000FF]gotoAndStop[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]lang == [COLOR=#FF0000]“Deutsch”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]_root[/COLOR].[COLOR=#0000FF]gotoAndStop[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]//=====================YEAR BUTTONS - FUNCTION CALLS TO OPERATE BUTTONS=========================================[/COLOR]
[COLOR=#808080]// Make functions play on rollover/rollout/press/release of Unit buttons[/COLOR]
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onRollOver[/COLOR] = growOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onRollOut[/COLOR] = shrinkOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onPress[/COLOR] = depress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] [COLOR=#000000]([/COLOR]lang = [COLOR=#FF0000]“Espanol”[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = unpress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Espanol_btn[/COLOR].[COLOR=#0000FF]onReleaseOutside[/COLOR] = unpressOutside;

[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Francais_btn[/COLOR].[COLOR=#0000FF]onRollOver[/COLOR] = growOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Francais_btn[/COLOR].[COLOR=#0000FF]onRollOut[/COLOR] = shrinkOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Francais_btn[/COLOR].[COLOR=#0000FF]onPress[/COLOR] = depress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Francais_btn[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = unpress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Francais_btn[/COLOR].[COLOR=#0000FF]onReleaseOutside[/COLOR] = unpressOutside;

[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Deutsch_btn[/COLOR].[COLOR=#0000FF]onRollOver[/COLOR] = growOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Deutsch_btn[/COLOR].[COLOR=#0000FF]onRollOut[/COLOR] = shrinkOverTime;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Deutsch_btn[/COLOR].[COLOR=#0000FF]onPress[/COLOR] = depress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Deutsch_btn[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = unpress;
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]Deutsch_btn[/COLOR].[COLOR=#0000FF]onReleaseOutside[/COLOR] = unpressOutside;

[COLOR=#0000FF]stop[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]

Here is the link to the movie to give you an idea if what I’m trying to achieve
[/COLOR][/COLOR]
http://www.mrdoodle.com/languagenut/
[COLOR=Blue][COLOR=Black]
Hopefully to some code wizard out there it will be decipherable as to what’s going on and how I can get this to work.

I thank you in advance for any help given.

Peace :party:[/COLOR][/COLOR]

search the forums it aint rocket science

ie this is so easy and comes up so often you would struggle not to find…

say a very simular topic posted today for example

I have been searching forums for the last three hours. Perhaps you think it’s not rocket science, but action script is not really my thing, and I was just trying to get a pointer in the right direction. i.e where do I define that the variable lang is to be Espanol if the Espanol_btn has been released.
The code I have at present is:


_root.Espanol_btn.onRelease (lang = "Espanol");

is this correct?

I know you probably think I’m stupid, but I just cannot seem to get this working. If you just want to direct me back to a forum could you at least give me an idea of what I should try typing in when I search for te appropriate post.

Thanks

Try this:
_root.Espanol_btn.onRelease = function() {
lang = “Espanol”;
unpress;
}

Change the other buttons too:

_root.Francais_btn.onRelease = function() {
lang = “Francais”;
unpress;
}
_root.Deutsch_btn.onRelease = function() {
lang = “Deutsch”;
unpress;
}

thanks glosrfc,

I have triend this already, but it doesn’t work.
It doesn’t seem to run the function unpress() when i do this. Instead of returning the button to the priginal position on Release it leaves it where it is.

function unpress() {
	if (this == Deutsch_btn) {
		lang = "Deutsch";
	} else if (this == Espanol_btn) {
		lang = "Espanol";
	} else {
		lang = "Francais";
	}
	trace (lang);
	this._x = this._x - 5;
	this._y = this._y - 5;
	// run 'navigate' function
	navigate();
}

Thanks so much for your help glosrfc. Very much appreciated.

I had actually got it working in the end myself. Only after many hours of experimentation though. However the code you suggested is alot more concise than what I had come up with, so have swapped it over.

It’s really good to know how to do the if else thing now. I know it’s good to learn things and work stuff out oneself, but to be shown an example relevant to the movie is often invaluable. And I think is just as good a way to learn. I mean I will never forget how to do this again now.

and just a small observation…
The sharing of knowledge is a beautiful thing. I don’t see the point when people answer posts - obviously knowing how to solve or at least assist with the problem - and then just tell the poster that it’s easy and they should go and search the answer out for themselves. It defeats the whole point of having a forum. Are they not there for people to get help and assistance with their questions and problems?

Thanks again for you help.

Mike