'if' function on button

hey, im a little unsure about how to do this - im sure its fairly simple, but i want my button to have a different action depending on whether an mc is playing - basically i have a few buttons, each with their own actions. but if one button has been pressed, id like the other button to close it’s movie before performing its own. i can put in the actions myself, im just unsure how to use the button with an ‘if’ function kinda thing. i hope someone can understand what im saying :stuck_out_tongue: and help me out.

cheers

Flash needs a case function

You mean switch (case)? It does. That might be useful here if you are using a bunch of nested if/else statements.

… can you explain ?

Seretha, sweet site by the way and nice tunes

hehe yeh explanation would be nice :slight_smile:

btw seretha thanks for the code, but it didnt work just now. i will give it another try in the morning, im probably just missing something simple like an instance name, but basically for the moment the

if (mcName == “mc1”) { etc

isnt working for me although the else bit works fine.

have you made the variable mcName = “mc1” anywhere in your .swf?

== checks for equality but = MAKES the variable equal to “mc1”…

put:
mcName = “mc1” at the beginning of the .swf and an action in the
if (mcName == “mc1”) {

and see if it does that action when pressed.

The ‘else’ will work if this isnt done because it’s not agreeing with any of the other statements.

~ Seretha :love:

I’d have to see your fla, or the code you are implementing to see if you actually would benefit from using switch/case (stupid me, always opening my mouth before I know the situation!) :sigh: but anyway, here is a link to how switch is used - written by my hero, Senocular :love: . It’s pretty simple to use so if you decide to implement it and still have questions let me know.

Feel free also to post your fla or code too. :bu:

ok thanks, maybe ill post my fla when i get home today.

seretha, i think the problem is that my mc1 is not actually in the main timeline - it appears when another button is pressed, maybe that would effect it?

and ill check out senocular’s tutorial, looks interesting :slight_smile:

put a _root. before all the variables ‘mcName’

~ Seretha :love:

Ok well im kinda frustrated, I’ve tried my best but still haven’t got the if part to work. i think you are right seretha, i need to put _root. in for the variable but i still couldnt get it to work with that - maybe i made a mistake. here is a link to my .fla, id appreciate if anyone could help.

Well, I’m not too good with arrays but it seems like in the function continueFade you are accepting only one mc as a variable? But when you call the function from within the function fadeMC then you are sending multiple mcs? Again, this could be perfectly legit and I’m just dumb but that might be something to look at. :ne:

hehe u talking about this .fla? cos if u are im very confused :stuck_out_tongue:

lol, yeah, I"m talking about these two functions here:
[AS]
function fadeMC(mcnr, speed) {
azcount++;
_root[“box”+mcnr].onEnterFrame = function() {
_root[“box”+mcnr]._alpha -= speed;
if (_root[“box”+mcnr]._alpha<=smoothness) {
_root[“box”+mcnr].onEnterFrame = null;
continueFade(_root[“box”+mcnr], speed);
mcnr += 1;
fadeOut(mcnr, speed);
}
};
}
function continueFade(mc, speed) {
mc.onEnterFrame = function() {
mc._alpha -= speed;
if (mc._alpha<=0) {
delete mc.onEnterFrame;
}
};
}
[/AS]

You are sending _root[“box”+mcnr] to the function continueFade so you are sending an entire array? But continueFade looks like it just accepting one mc?

Like I said, this could have nothing to do with the problem you are having and could be just me being a stoopid-head :trout:

oh that. yeh the symbol ‘box’ is actually for the grid effect on the image load. its kinda in the background, so i wouldnt think it would affect any of my other actions?

btw im looking at the first link you gave me in this topic, it looks to do what im trying to do :wink: dont know why it crashed my mx last time, it works fine now. ill tell u how it goes in a min, hopefully :stuck_out_tongue:

nope. its got the right idea but im too noobish to understand how to change it to what i need :stuck_out_tongue:

ah well, if no one else has got any ideas i think i should probably give up…