School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,574 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,199 people online right now. Registration is fast and FREE... Join Now!




AS2 rollOut - Do not want to snap back to 1 but instead glide back to

 

AS2 rollOut - Do not want to snap back to 1 but instead glide back to

Adaptive

16 Jan, 2009 - 07:56 PM
Post #1

New D.I.C Head
*

Joined: 16 Jan, 2009
Posts: 3

Let me start off by saying hello
I'm new here from the US.

So anyways. I have this little project I'm working on.
I have successfully created the buttons and mouse over movies and everything works great.
But on when the mouse rolls out the button just snaps back to 1. Yes this is how it is supposed to be...
BUT instead of snapping back to frame 1 I would like it to GLIDE or FADE back to frame 1.



The button in the code below is 10 frames with stop frame at 10.
On frame 11 I made the reversal of frames 1 - 10 to fade the button back in to 100% alpha.

for an example:
The button goes from 100% alpha to 0% (frame 1 - 10) on rollover
ON rollout it snaps back to frame 1 with 100% alpha. (this is what is supposed to happen but not what I want).
I want to make the roll out fade from 0% alpha to 100% alpha on roll out.


CODE

Neither code does what I am looking for

this.pro.onRollOut = function(){
    gotoAndStop._11 = 100;
}

this.pro.onRollOut = function(){
    gotoAndPlay._11 = 100;
}




I found this thread.
http://www.dreamincode.net/forums/index.ph...c=15726&hl=
Not exactly what I'm looking for, but I believe the original poster was looking for similar answer that I am seeking.

I hope I have been descriptive enough.
If not I found this website.... (not the one I am working on)
http://www.makeupforever.fr/
If you mouse over the center it does whatever (this is not a problem for me to make)
but when you mouse out it GLIDES/FADES back to frame 1.... this is what i want!!

=)

This post has been edited by Adaptive: 16 Jan, 2009 - 07:58 PM

User is offlineProfile CardPM
+Quote Post


parker_as3

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

18 Jan, 2009 - 11:27 PM
Post #2

New D.I.C Head
*

Joined: 18 Jan, 2009
Posts: 3


My Contributions
QUOTE(Adaptive @ 16 Jan, 2009 - 07:56 PM) *

Let me start off by saying hello
I'm new here from the US.

So anyways. I have this little project I'm working on.
I have successfully created the buttons and mouse over movies and everything works great.
But on when the mouse rolls out the button just snaps back to 1. Yes this is how it is supposed to be...
BUT instead of snapping back to frame 1 I would like it to GLIDE or FADE back to frame 1.



The button in the code below is 10 frames with stop frame at 10.
On frame 11 I made the reversal of frames 1 - 10 to fade the button back in to 100% alpha.

for an example:
The button goes from 100% alpha to 0% (frame 1 - 10) on rollover
ON rollout it snaps back to frame 1 with 100% alpha. (this is what is supposed to happen but not what I want).
I want to make the roll out fade from 0% alpha to 100% alpha on roll out.


CODE

Neither code does what I am looking for

this.pro.onRollOut = function(){
    gotoAndStop._11 = 100;
}

this.pro.onRollOut = function(){
    gotoAndPlay._11 = 100;
}




I found this thread.
http://www.dreamincode.net/forums/index.ph...c=15726&hl=
Not exactly what I'm looking for, but I believe the original poster was looking for similar answer that I am seeking.

I hope I have been descriptive enough.
If not I found this website.... (not the one I am working on)
http://www.makeupforever.fr/
If you mouse over the center it does whatever (this is not a problem for me to make)
but when you mouse out it GLIDES/FADES back to frame 1.... this is what i want!!

=)

you should use a enterframe that detects whether or not you have rolled over the object or rolled out using booleans.
like this:
CODE

//stops the animation from playing out intially
rollbox_mc.stop();

// sets truefalse datatype to boolean and by default it is false
var truefalse:Boolean = false;

//if you roll over the object its true
rollbox_mc.onRollOver = function() {
    trufalse = true;
};

// if you roll out of the object its false
rollbox_mc.onRollOut = function() {
    trufalse = false;
};

//checks if its true on every frame and if it is then proceed to the next frame
//else if it is false then reverse frames
rollbox_mc.onEnterFrame = function() {
    if (trufalse == true) {
        rollbox_mc.nextFrame();
    } else {
        rollbox_mc.prevFrame();
    }
};

there is a alternative(as is usually the case) using hitTest but i thought i would give you an easier to understand solution.
cheers smile.gif

This post has been edited by parker_as3: 18 Jan, 2009 - 11:34 PM
User is offlineProfile CardPM
+Quote Post

thehat

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

19 Jan, 2009 - 05:34 AM
Post #3

awake ? web();
Group Icon

Joined: 28 Feb, 2008
Posts: 894



Thanked: 90 times
Dream Kudos: 175
My Contributions
The way I do this in as2 is fairly simple.

First, you create your 'button', which is actually a movieclip. Lets assume that your animation lasts for 5 frames. The first frame should be static, with a stop, and show the default state of your button. The second frame is the same as the first, but with a label of 'rollover'. Frame 6 will contain the finished rollover state, be it a color chage or whatever. Put a stop on this frame, and create a tween between frames 2 and 6. Next copy the contants of frame 6 to frame 7. Give frame 7 a label of 'rollout'. Move to frame 11, and make this a copy of frame 1, with a stop, and create a tween between frames 7 and 11.

The code to control this, to be placed on the same timeline as the 'button' is:
as

my_button.onRollOver = function() {
my_button.gotoAndPlay("rollover");
}

my_button.onRollOut = function() {
my_button.gotoAndPlay("rollout");
}


I've attached an example in case my wall of text isn't too easy to follow!




Attached File(s)
Attached File  simple_smooth_button.zip ( 5.91k ) Number of downloads: 49
User is offlineProfile CardPM
+Quote Post

Adaptive

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

21 Jan, 2009 - 09:58 PM
Post #4

New D.I.C Head
*

Joined: 16 Jan, 2009
Posts: 3

QUOTE(parker_as3 @ 18 Jan, 2009 - 11:27 PM) *

QUOTE(Adaptive @ 16 Jan, 2009 - 07:56 PM) *

Let me start off by saying hello
I'm new here from the US.

So anyways. I have this little project I'm working on.
I have successfully created the buttons and mouse over movies and everything works great.
But on when the mouse rolls out the button just snaps back to 1. Yes this is how it is supposed to be...
BUT instead of snapping back to frame 1 I would like it to GLIDE or FADE back to frame 1.



The button in the code below is 10 frames with stop frame at 10.
On frame 11 I made the reversal of frames 1 - 10 to fade the button back in to 100% alpha.

for an example:
The button goes from 100% alpha to 0% (frame 1 - 10) on rollover
ON rollout it snaps back to frame 1 with 100% alpha. (this is what is supposed to happen but not what I want).
I want to make the roll out fade from 0% alpha to 100% alpha on roll out.


CODE

Neither code does what I am looking for

this.pro.onRollOut = function(){
    gotoAndStop._11 = 100;
}

this.pro.onRollOut = function(){
    gotoAndPlay._11 = 100;
}




I found this thread.
http://www.dreamincode.net/forums/index.ph...c=15726&hl=
Not exactly what I'm looking for, but I believe the original poster was looking for similar answer that I am seeking.

I hope I have been descriptive enough.
If not I found this website.... (not the one I am working on)
http://www.makeupforever.fr/
If you mouse over the center it does whatever (this is not a problem for me to make)
but when you mouse out it GLIDES/FADES back to frame 1.... this is what i want!!

=)

you should use a enterframe that detects whether or not you have rolled over the object or rolled out using booleans.
like this:
CODE

//stops the animation from playing out intially
rollbox_mc.stop();

// sets truefalse datatype to boolean and by default it is false
var truefalse:Boolean = false;

//if you roll over the object its true
rollbox_mc.onRollOver = function() {
    trufalse = true;
};

// if you roll out of the object its false
rollbox_mc.onRollOut = function() {
    trufalse = false;
};

//checks if its true on every frame and if it is then proceed to the next frame
//else if it is false then reverse frames
rollbox_mc.onEnterFrame = function() {
    if (trufalse == true) {
        rollbox_mc.nextFrame();
    } else {
        rollbox_mc.prevFrame();
    }
};

there is a alternative(as is usually the case) using hitTest but i thought i would give you an easier to understand solution.
cheers smile.gif




Sweet, do you have any samples using the method you described, I have no clue with booleans so I will have to do some research before i attempt it. With this would I have to make a reversal of the rollOVER or would the booleans reverse the over automatically or something? Got an email address or aim?


QUOTE(thehat @ 19 Jan, 2009 - 05:34 AM) *

The way I do this in as2 is fairly simple.

First, you create your 'button', which is actually a movieclip. Lets assume that your animation lasts for 5 frames. The first frame should be static, with a stop, and show the default state of your button. The second frame is the same as the first, but with a label of 'rollover'. Frame 6 will contain the finished rollover state, be it a color chage or whatever. Put a stop on this frame, and create a tween between frames 2 and 6. Next copy the contants of frame 6 to frame 7. Give frame 7 a label of 'rollout'. Move to frame 11, and make this a copy of frame 1, with a stop, and create a tween between frames 7 and 11.

The code to control this, to be placed on the same timeline as the 'button' is:
as

my_button.onRollOver = function() {
my_button.gotoAndPlay("rollover");
}

my_button.onRollOut = function() {
my_button.gotoAndPlay("rollout");
}


I've attached an example in case my wall of text isn't too easy to follow!





Yeah this is the same though process I had. I was not able to get it to work my way because I am not too good at coding, so when I get home I'll certainly give your method a go. This should be very easy for me because it seems like we are on the same brain frequency here. But will the code/method work... hopefully; that will be the test! =)

Thanks soo much for the reply icon_up.gif
User is offlineProfile CardPM
+Quote Post

Xeophex

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

5 Feb, 2009 - 05:18 PM
Post #5

New D.I.C Head
*

Joined: 5 Feb, 2009
Posts: 1

Did you manage to get it working Adaptive? Which method? I'm after the same solution myself.
User is offlineProfile CardPM
+Quote Post

Adaptive

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

6 Feb, 2009 - 09:37 AM
Post #6

New D.I.C Head
*

Joined: 16 Jan, 2009
Posts: 3

QUOTE(Xeophex @ 5 Feb, 2009 - 05:18 PM) *

Did you manage to get it working Adaptive? Which method? I'm after the same solution myself.



Didn't try yet, got more work thrown on my lap. grrr that always happens
hope to do it this week though


hehe
User is offlineProfile CardPM
+Quote Post

fishka

RE: AS2 RollOut - Do Not Want To Snap Back To 1 But Instead Glide Back To

29 May, 2009 - 12:08 PM
Post #7

New D.I.C Head
*

Joined: 29 May, 2009
Posts: 1

TheHat,

I'm a new flash user and I had the same issue as the original post. I have been searching on all sorts of forums for the past few days and
when I found your suggestion I tried it.

Here is what I have, Im not sure why its not working- its messing up my other actions (the actions, such as stops, in my other movie clips that were already in place).... Any ideas? maybe something with the as2 ...though I thought my actionstript was as2 as well..


Thank you for your help!

This post has been edited by fishka: 29 May, 2009 - 12:10 PM


Attached File(s)
Attached File  flash_movie_052809.zip ( 576.94k ) Number of downloads: 25
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 08:14AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month