Welcome to Dream.In.Code
Getting Help is Easy!

Join 119,058 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,521 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



onRollOver, onRollOut, onRelease.

 
Reply to this topicStart new topic

onRollOver, onRollOut, onRelease.

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


New D.I.C Head

*
Joined: 12 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

Go to the top of the page


BetaWar
post 4 Aug, 2008 - 12:52 AM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,695



Thanked 64 times

Dream Kudos: 1075
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

Go to the top of the page

cadeownz
post 4 Aug, 2008 - 09:54 PM
Post #3


New D.I.C Head

*
Joined: 12 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

Go to the top of the page

BetaWar
post 4 Aug, 2008 - 11:31 PM
Post #4


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,695



Thanked 64 times

Dream Kudos: 1075
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

Go to the top of the page

tzer
post 6 Aug, 2008 - 11: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 - 11:38 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 03:41PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month