Welcome to Dream.In.Code
Become an Expert!

Join 136,886 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,726 people online right now. Registration is fast and FREE... Join Now!




onRollOver, onRollOut, onRelease.

 
Reply to this topicStart new topic

onRollOver, onRollOut, onRelease.

cadeownz
3 Aug, 2008 - 09:14 PM
Post #1

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

hey,
i have a movie clip that when i roll over it gets highlighted:
on(rollOver){ gotoAndStop(2);}
on roll out it goes back to frame 1 which isnt highlighted:
on(rollOut){ gotoAndStop(1)}
when i release it goes to frame 3:
on(release){ gotoAndStop(3)}
BUT when i release then rollout it does the rollout action and goes to frame 1. i wont it to stay on frame 3 even when i rollout. Is it possible? Plz need help..
Thanks in advance
smile.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif ph34r.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif smile.gif
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: OnRollOver, OnRollOut, OnRelease.
3 Aug, 2008 - 11:52 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
My Contributions
When you are wanting buttons to be able to be toggled you need to add a true/false variable that states if they are toggled or not.

Try this code )placed inside the movieclip for this example):
CODE
this.stop();
var toggled:Boolean = false;
this.onRollOver = function(){
    if(this.toggled == false){
        this.gotoAndStop(2);
    }
}
this.onRollOut = function(){
    if(this.toggled == false){
         this.gotoAndStop(1);
    }
}
this.onRelease = function(){
    this.gotoAndStop(3);
    if(this.toggled == false){
        this.toggled = true;
    }
    else{
        this.toggled = false;
    }
}


Hope that helps.
User is online!Profile CardPM
+Quote Post

cadeownz
RE: OnRollOver, OnRollOut, OnRelease.
4 Aug, 2008 - 08:54 PM
Post #3

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

hey thnx for trying to help but i dont compltetly understand that. it doesnt seem to work. like do i need to add anything to it? i need a functonally code if possible. thnx 4 helping tho biggrin.gif smile.gif biggrin.gif
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: OnRollOver, OnRollOut, OnRelease.
4 Aug, 2008 - 10:31 PM
Post #4

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,032



Thanked: 82 times
Dream Kudos: 1175
My Contributions
Okay here is a walk though on how to use the given code (above).

1 - Create your button movieclip with the 3 keyframes (1 2 and 3)
1.5 - Place the button stuff in each of the keyframes
2 - Create a new layer that spans the 3 keyframes (above the first layer in the same movieclip)
3 - Place the code in the new layer
4 - Test it out (should work, I am using AS 2.0 in Flash 8 Professional and it works perfectly fine with that).

Hope that helps.
User is online!Profile CardPM
+Quote Post

tzer
RE: OnRollOver, OnRollOut, OnRelease.
6 Aug, 2008 - 10:35 PM
Post #5

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 4



Thanked: 1 times
My Contributions
There are quite few way to do it, but i try to make simple and nearest your scripting style.

CODE
on(rollOver){
    if(!pressed)
        gotoAndStop(2);
}
on(rollOut){
    if(!pressed)
        gotoAndStop(1);
}
on(release){
    gotoAndStop(3);
    pressed = true;
}


what i added is rollover and rollout event depending on a "pressed" variable. "pressed" default value is false, and rollover and rollout event only work if the "pressed" is set to true. after release, "pressed" is set to true which make rollover and rollout stop working.

hope this help.

This post has been edited by tzer: 6 Aug, 2008 - 10:38 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 08:46PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month