PDA

View Full Version : scripted menu


finksmart
04-09-2004, 02:53 PM
Hello and great forum. This is my first post and here is my question.

First Go to http://www.eccentris.com/flash.htm then choose "Detour", and here are my two questions:

1. I understand simple scripted movement but how is the menu on the right scripted such that the grey rectangle highlights the page you're in; and how is it that the grey rectangle stays in position when the mouse moves within the rectangle.

2. This has boggled for a while. To the left when the content slides into position, how is it scripted such that it slowly eases in, while displaced, then completes the photo and everything falls into place?

All help is greatly appreciated.

Ruben
04-09-2004, 05:34 PM
A warm welcome, I'd say...

Answer to you first question:
My guess is that all of the buttons on the right are transparent buttons placed on a layer on top of the texts or something.
Whenever you place your mousepointer on one of the buttons some trigger-variable is set to true or something and that would trigger the semi-transparent square to do some stuff.
The script on the semi-transparent square and the button would be something like this:

//// code for button [on frame, not button]:
_root.somebutton.onRollOver = function(){
// Tell the movie that the y-value that is the stop-point is the _y of this button:
_root.yValueVar = _root.somebutton._y;
// Tell the movie what the speed is:
_root.speed = 10
}
_root.somebutton.onRollOut = function(){
_root.yValueVar = _root.standardHighlightedButton._y;
}
//// code for frame1:
// This is the easing part [just letting the speed depend on what the distance between point A and point B is]:
_y += (_root.yValueVar - _y) / _root.speed;
//// code for frame2:
gotoAndPlay(_currentframe-1)


Answer to you second question:
I guess it's done with several instances of the same movieclip, inside it the image is masked and on the level above the clip is told where to place the image...It's kind of difficult to explain, I'll do you a sample if you want to....

Goodnight anyways... ;) - Ruben

finksmart
04-19-2004, 03:08 AM
Hey Ruben, thanks for the reply. Sorry I didn't get a chance to read it. But I tried your approach and it didn't seem to work. Before I read your reply tho, I figured out a script from the tutorials that makes an MC (call it MC1) follow the mouse and that's it. So now how would I call the motion from a button that's inside another MC (call it MC2), such that when you move the mouse over the button, or on rollover, MC1 moves over to the button that's inside MC2 horizontally. This is very much like the menu system in www.eccentris.com under "Detour", except i'm trying to do it horizontally. The script I currently have for the simple mouse following is as follow:


onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.xChange = Math.round(_root._xmouse-this._x);
_root.xMove = Math.round(_root.xChange/5);
this._x += _root.xMove;
}


Basically, the script allows the MC to follow the mouse but i would like to MC to stay still when the mouse is over a button. I can send you the file if you don't mind taking a look at it.

Ruben
04-19-2004, 04:54 AM
Got a moment? I'll make you a sample...

- Ruben

Ruben
04-19-2004, 05:14 AM
Seems you did have a moment ;)

Anyways, check the attachement and go nuts with it...If your still left with questions don't be shy to post :p

- Ruben

finksmart
04-19-2004, 01:34 PM
Thanks Ruben. I'll keep you posted on my progress.

finksmart
04-19-2004, 01:41 PM
Hey Ruben,

It seems that what I need is rather particular, and I'm a bit confused as I'm fed more scripts. Could I email you the flash file and tell you exactly what it is that I'm boggled by? :confused:

Ruben
04-19-2004, 01:54 PM
Why not zip the fla and attach it so others can learn from it as well?

:p - Ruben

finksmart
04-19-2004, 02:35 PM
Of couse! Here is the file.

Ok here is what I'm looking for. There are 2 MC's and they both have scripts in them. I would like to make it so that when you roll over a button, the grey rectangle moves over the button (with easing) and shorten in length to fit the button. After you click to go to a particular page, the rectangle stays over the button that denotes that page to let the viewers know that's where they are. You'll see that I may already have script for the MC's and that's my confustion as I may understand how to do scripted movement from the tutorials here on as.org but I am not bright enough to tweak it to what i want. :(

Ruben
04-19-2004, 03:25 PM
Well, I could do you a sample [and I will if you want me to]...But since I'm kinda busy at the moment and I figured you'd want the answer as soon as possible I'll just explain what I'd do:

- First of all, the main thing is telling the 'slider' where to go when a button is clicker, rolled over or rolled out;
- For the button, use a script that looks somewhat like this:
button1.onRelease=function(){
_root.selected = 1;
}
button1.onRollOver=function(){
_root.gohere = 1;
}
button1.onRollOut=function(){
_root.gohere = "";
}
- For the 'slider', use this something like this:
// script for frame1:
if (_root.gohere != ""){
_x+=(_parent["button"+_root.gohere]._x-_x)/10;
}else{
if (_root.selected==undefined){
_x+=(0-_x)/10; // zero represents the _x the slider goes to when no button's selected
}else{
_x+=(_parent["button"+_root.selected]._x-_x)/10;
}
}
// script for frame2:
gotoAndPlay(_currentframe-1);

That should do it ;)

NOTE: Didn't test it...so there could [though I don't think so] be some bugs in the script :p

- Ruben

finksmart
04-19-2004, 03:31 PM
Thanks Ruben! Let me go try it out and i'll let you know how it went.

finksmart
04-19-2004, 03:36 PM
For the code for the button, should i place it in the main timeline or the MC that contains the buttons?

finksmart
04-19-2004, 03:47 PM
Question: what does the "1" mean in _root.gohere = 1?

Ruben
04-19-2004, 03:48 PM
Well, doesn't matter really, as long as the paths of the buttons are correct in the "button1.onRelease=function(){"-part

- Ruben

Ruben
04-19-2004, 03:49 PM
The "1" stands for the id of the button....

- Ruben

finksmart
04-19-2004, 04:05 PM
sorry for the bombardment, but how do i assign an ID to the button?

Edit: If my questions are starting to get annoying, i must apologize. Could you maybe make a sample at your convenience? Thank you so very much.

finksmart
04-20-2004, 02:59 PM
I finally figured it out. I'll show you guys when the site is ready. Thanks for your help Ruben! =)

Ruben
04-20-2004, 03:00 PM
Yeah, no problem...

:) - Ruben