PDA

View Full Version : button on clip on animation on navigation on . . .



lunatic
October 4th, 2003, 12:06 AM
Harumph. This seems like it should be really simple but for some reason it's just not working for me.

I have a sliding menu (who doesn't these days? :sigh: ) at the bottom of my screen. When you mouse over the menu it pops up and as it does it triggers an animation of a moving object. The moving object starts "off screen", comes sliding in and comes to a rest in the middle of the menu. The object has buttons on it. What I'd like to do is when a user clicks the button it loads content onto the main stage. Then either after clicking the button or mousing off the menu the object animation will continue on it's merry way out of view (off the menu).

Everything works great except I can't get the **** button to work!

I'm thinking it's a path issue since I've done lots of buttons.

So the button is now here:
_root.slidingNav.animationMC.object.button

and I've got the AS on the button:

on (release) {
_root.slidingNav.animation.gotoAndPlay(31);}

Is the button so buried that it's clicking options aren't available? I've never heard of that before but I'm still new so . . .

Any help? :bu:

Voetsjoeba
October 4th, 2003, 02:52 AM
Well if it's a path issue we have to see the fla ...

lunatic
October 4th, 2003, 01:19 PM
You would wouldn't ya? :azn:

Okay, here it is. I'm sure it's something really simple and I'm going to say "Well, duh! Why didn't I think about that?"

Do we have a smiley yet of a guy smackin' his forehead? I guess the trout is pretty close . . .

lunatic
October 5th, 2003, 02:27 PM
So I tried this a couple of different ways - I made a button with AS "on release" on the trainMC, and I also tried making a movie clip with button actions on it on the 30th frame of the trainIn animation MC but neither one seems to work.

How do you make a button do something if it only appears on the 30th frame of an animated movie clip?

Thanks for any help! (-:

lunatic
October 6th, 2003, 12:33 AM
Anyone? :nerd:

Hard to move forward without getting this straightened out. Anyone got any ideas?

(-:

Voetsjoeba
October 6th, 2003, 01:45 PM
It's because you use the onRollOver handler of the movieclip in which the button is contained. That disables the button inside from working. So what you have to do is create another onEnterFrame handler to check if _ymouse and _xmouse hitTest with the movieclip instead of using it's onRollOver handler. So replace the code with this:



fscommand("allowscale", "false");
//Begin action for sliding menu
tarY = 580;
this.onEnterFrame = function() {
if (slidingNav.hitTest(_xmouse, _ymouse)) {
_root.slidingNav.trainIn.gotoAndPlay(2);
delete this.onEnterFrame;
}
};
slidingNav.onEnterFrame = function() {
if (this.hitTest(_xmouse, _ymouse)) {
tarY = 499;
} else {
tarY = 580;
}
this._y = tarY-(tarY-this._y)/1.4;
};

:)

lunatic
October 6th, 2003, 02:29 PM
Sweet! I always forget about onEnterFrame because I'm never really sure how to use it. I'll try that out when I get home (I'm at work and no Flashing allowed :*( ). I'm sure it will work though because you are the MAN.

P.S. Did I say "thank you?" :beam:

Voetsjoeba
October 6th, 2003, 02:47 PM
You sure did now ;) Welcome mate :)

lunatic
October 6th, 2003, 08:54 PM
Home now, and it works great!

Pardon my stupidity :smirk: but I have two questions.

first - what does "delete this.onEnterFrame" do?

and second - how do I "reset" it so that when the user rolls off the menu and it slides back down the train animation gets reset so that when you roll over it again it replays the animation again?

Thanks!

radicaljugnu
October 7th, 2003, 03:03 AM
"delete this.onEnterFrame" will simply stop the onEnterFrame, that is, it will stop doing the stuff in the enterFrame event handler.

lunatic
October 7th, 2003, 11:47 AM
Ahh . . .

That makes sense, but then why does it only happen once? Shouldn't it refresh itself everytime the hit test proves true? It seems to work fine for the slidingNav moving up and down (tarY part of code).

If so, then I would assume that that would reset the animation of the train rolling in? I want that animation to start every time the user mouses over the slidingNav, provided a button was clicked (on the animation) triggering the 2nd half of the tween.

E.g. mouse over the menu --> train rolls in. User clicks a button, train rolls out (AS for this is on the button), train resets for next mouseover. If user mouses off without clicking a button, train sits, even though slidingNav goes up and down on mouseover regardless.

Okay, I'll stop since I'm confusing myself . . .:h:
What am I missing here?

Voetsjoeba
October 8th, 2003, 10:17 AM
Replace the stop() action at the last frame of the train animation with


gotoAndStop(1);
_parent._parent.onEnterFrame = function() {
if (this.slidingNav.hitTest(this._xmouse, this._ymouse)) {
this.slidingNav.trainIn.gotoAndPlay(2);
delete this.onEnterFrame;
}
};
I'm confused about the train staying to "sit" when no button is clicked ...

lunatic
October 12th, 2003, 02:07 PM
Hey V,

Thanks! That works really great (of course). Sorry I didn't get back sooner, I've been out of town too. Hope you enjoyed the film festival!

I guess what I'm trying to get at is:

1) user rolls over menu, train slides in and stops

2a) IF user rolls off menu without clicking a button then train sits there so that when user rolls over menu again the train is still just sitting there.

2b) IF user clicks a button then the train rolls out but then is ready to roll in again the next time the user rolls over the menu

The code you suggested works perfectly with one teensy exception - if the user clicks a button but DOESN'T roll off the menu (in other words the menu remains "up") then after the train rolls out it rolls in again.

But this I can live with for now. I'll dink around and see if I can fix that (hah hah) but it's pretty minor compared to the other functionality which now works! Thanks again! :thumb:

Voetsjoeba
October 12th, 2003, 02:38 PM
Replace the actions on the last frame of the train animation with these:


gotoAndStop(1);
_parent._parent.onEnterFrame = function() {
if (!this.isOn) {
this.onEnterFrame = function(){
if(this.isOn){
this.slidingNav.trainIn.gotoAndPlay(2);
delete this.onEnterFrame
}
};
}
};


And replace those on the main timeline with these:



fscommand("allowscale", "false");
//Begin action for sliding menu
tarY = 580;
this.isOn = false;
this.onEnterFrame = function() {
if (slidingNav.hitTest(_xmouse, _ymouse)) {
_root.slidingNav.trainIn.gotoAndPlay(2);
delete this.onEnterFrame;
}
};
slidingNav.onEnterFrame = function() {
if (this.hitTest(_xmouse, _ymouse)) {
tarY = 499;
isOn = true;
} else {
tarY = 580;
isOn = false;
}
this._y = tarY-(tarY-this._y)/1.2;
};

;)

lunatic
October 12th, 2003, 05:57 PM
Dude, how do you DO it? :stunned: You are so dang smart! Works like a charm . . .

. . . . thank you (humbled).

:snug:

Voetsjoeba
October 13th, 2003, 01:15 PM
You're welcome =)