-
Toggle Button Problem
Hey Guys,
I thought I'd try out this forum since it is more dedicated to Flash than my other forum. Basically, I have a button that when moused over it makes rivers go to 50% opacity (they start at 10%), then when clicked they go to 100%.
What I WANT:
Then the rivers stay at 100% until the user clicks the button again.
What is HAPPENING:
Currently though the mouseout is fading the rivers back to 10%. I know that my code is telling it to do that and want to know how to make it stop.
Here is my code for this:
Code:
Code:
function shipMouseOver(event:MouseEvent):void {
Tweener.addTween(rivers_mc, {alpha: 1, time:2});
Tweener.addTween(this.dashboard_mc.ship_btn, {alpha: 1, time:2});
}
function shipMouseOut(event:MouseEvent):void {
Tweener.addTween(rivers_mc, {alpha: .1, time:2});
Tweener.addTween(this.dashboard_mc.ship_btn, {alpha: .5, time:2});
}
function shipClick(event:MouseEvent):void {
if(shipState == "on") {
shipState = "off";
Tweener.addTween(rivers_mc, {alpha: .10, time:2});
}
else {
shipState = "on";
Tweener.addTween(rivers_mc, {alpha: 1, time:2});
}
}
PS. If anyone has a quick way for doing the event listeners as I have 9 more buttons that have to do this same thing - that would be great.
--
Greg
-
So I posted on 4 forums and no replys - but I finally solved the issue - here's what I did:
Code:
Code:
function shipClick(event:MouseEvent):void {
if(shipState == "on") {
shipState = "off";
Tweener.addTween(rivers_mc, {alpha: .10, time:2});
this.dashboard_mc.ship_btn.addEventListener(MouseEvent.ROLL_OUT, shipMouseOut);
}
else {
shipState = "on";
dashboard_mc.ship_btn.removeEventListener(MouseEvent.ROLL_OUT, shipMouseOut);
Tweener.addTween(rivers_mc, {alpha: 1, time:2});
}
}
Hope that helps someone else.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|