Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-17-2004, 07:20 AM   #1
visualizer29
Registered User
 
Join Date: Jun 2004
Posts: 1
Default Movieclip plays - despite condition!

I have a movie with 2 buttons - button1 and button2.

Each button is a movieclip and consists of 2 layers :

Layer 1 contains an 11-frame animation which fades
the text "button 1" up and down through tweening
the alpha from 30 to 100 and back to 30 again.

Layer 2 contains a button with alpha set to 0, this
button spands through the entire animation. The button
is assigned actions that moves the playhead to the
appropriate locations in the animation, when on(rollOver)
and on(rollOut)-events occur; making the text "button 1"
light up when the mouse goes over it, and fades it out
to alpha 30 when the mouse goes away.

This all works very good, but I also want to keep the button
"turned on" when I press it. So I create another layer in my
main movie - on top of the layer with the button in it.
In this layer I create a movie clip with the text "button 1"
in it, and make 2 frames; frame 1 with the alpha set to 0 and
frame 2 with the alpha set to 100 - both frames are assigned
the stop-action. I call the instance of this movieclip "button1On".

Now when the on (press) event on button 1 occurs, the actions
in button 1 tell the playhead in "button1On" to go to frame 2 -
and "turn on" the button by setting it to alpha 100. This works
well too.

Now comes the problem :
I want to have another button in my movie ; "button 2" and I want
thês button to do the same thing as "button 1" - no problem, I
create another button. However, if "button 1" is turned on -
(which means that the playhead in the movieclip "button1On" is placed in frame 2), then I want the on (press) handler in "button 2"
to turn "button 1" off. So I assign the following script to button 2:

on (press) {

if (_root.button1On._currentframe = 2) {

_root.button1On.gotoAndStop(1);

}
}

Great! - It works! - when "button 1" is on, and I press "button 2" -"button 1" is turned off!

Now let´s spice it up a bit: What if I want a little animation to play, when I press "button 2", say...an animation showing "button 1" slowly turning off? Well..I make a movieclip showing a fading "button 1" I place it on a separate layer and name the instance of it "button1TurnOff" and I am ready to go!
Hey!
Wait a minute!...naturally this animation should only play if and ONLY if "button 1" is on - so I include the script to play "button1TurnOff" in the if-statement - the script in "button 2" now looks like this:

on (press) {

if (_root.button1On._currentframe = 2) {

_root.button1On.gotoAndStop(1);
_root.button1TurnOff.gotoAndPlay(2);
}
}

This also works: When "button 1" is on, and I press "button 2"
"button 1" not only turns off, but the animation "button1TurnOff"
plays as well! The only problem is....when I press the "turned on" button 2, the animation "button1TurnOff" plays again!???

How can this be?? The if statement checks to see if
"button1On" is in frame 2, which it isn´t, because we set the playhead to frame 1 with the first press on "button 2"?? But this condition is ignored and the clip "button1TurnOff" plays again?


Can anyone explain this?? Please!!

P.S: I included the .fla for you to see!
Attached Files
File Type: zip buttons.zip (7.9 KB, 567 views)
visualizer29 is offline   Reply With Quote
Old 06-17-2004, 07:55 AM   #2
hooman
Registered User
 
Join Date: Jun 2004
Posts: 41
Default i can't help, but...

...your thorough explanation helped me figure out how to use an 'if' statement for something i've been stuck on for awhile.

thanks!
hooman is offline   Reply With Quote
Old 06-17-2004, 05:29 PM   #3
Slowburn
[Invent:Design:Create]
 
Join Date: Sep 2002
Location: Toronto, ON
Posts: 2,068
Default

I think your file is MX04 format, I cannot open this....
__________________
o Please do a search before you post
o Please use the [ as][ /as] tag for your code (so we can read it clearly)
Slowburn is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:14 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.