Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : Setting up a selected/on variable


complexity
5/9/2005 12:00:00 AM
Hi all,

I have a menu with 2 options. Each are seperate mc's and inside them I have 2
states/label names "on" and "off".

All I want to have happen is when I roll my mouse over the menu option, the
mc is to go to the "on" state on the option I have just selected and then for
the other option to realise ok I now must go to my "off" state.

I thought I would do it like this:


set a global variable on the fiurst frame of the entire movie
portwebinfo = "1"


then inside _root.content_mc.port_web_mwe_info.:


if (portwebinfo == "1"){
_root.content_mc.port_web_mwe_info.mwe_port_tab_about.gotoAndStop("on");
} else {
_root.content_mc.port_web_mwe_info.mwe_port_tab_about.gotoAndStop("off");
}

if (portwebinfo == "2"){
_root.content_mc.port_web_mwe_info.mwe_port_tab_challenge.gotoAndStop("on");
} else {
_root.content_mc.port_web_mwe_info.mwe_port_tab_challenge.gotoAndStop("off");
}

and inside each of the movie option mc's (mwe_port_tab_about &
mwe_port_tab_challenge) I have:

// for mwe_port_tab_about
on (rollOver) {
portwebinfo = "1"
}

// for mwe_port_tab_challenge
on (rollOver) {
portwebinfo = "2"
}


But at present when I run the movie and roll over nothing happens.

Any help would be much appreciated.
GaryCCY
5/9/2005 12:00:00 AM
Hi

If you do
_global.portwebinfo = "1"
then try
on (rollOver) {
_global.portwebinfo = "2"
complexity
5/9/2005 12:00:00 AM
Hi GaryCCY have tried this but still the same result. I assume then that I am
doing something wrong with my main if statements:


if (portwebinfo == "1"){
_root.content_mc.port_web_mwe_info.mwe_port_tab_about.gotoAndStop("on");
} else {
_root.content_mc.port_web_mwe_info.mwe_port_tab_about.gotoAndStop("off");
}

if (portwebinfo == "2"){
_root.content_mc.port_web_mwe_info.mwe_port_tab_challenge.gotoAndStop("on");
} else {
_root.content_mc.port_web_mwe_info.mwe_port_tab_challenge.gotoAndStop("off");
}

These are just still inside a frame as is, Ive been told I should put them in
a loop, how would you go about doing that?
complexity
5/10/2005 12:00:00 AM
GaryCCY
5/10/2005 9:06:29 AM
hi

From the info given, in the onRollOver, you change a variable's value and base
on that value, make both movie clip to jump to a specific frame. However, you
have never mention something like *watching* that variable so it will call the
jumping automatically. I forget to check that in my previous post.

//Create an object with a property, ie "portwebinfo"
keyvar = {portwebinfo:0};
//Add a watch to this property, link it to a function
keyvar.watch("portwebinfo", doSomething, "");
//Define the function
function doSomething(){
//Jumps to frame depends on value of portwebinfo
}

If you are already doing that in your program and still not working, plz let
us know.
GaryCCY
5/11/2005 7:54:40 AM
Oops :-P

AddThis Social Bookmark Button