# \*\*\*\* 2 Simple questions \*\*\*\*

**URL:** <https://forum.kirupa.com/t/2-simple-questions/26766>\
**Category:** flash\
**Created:** [July 26, 2003, 2:37am UTC](https://forum.kirupa.com/t/2-simple-questions/26766 "2003-07-26T02:37:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vulcan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_vulcan/32/145_2.png) [@The\_Vulcan](https://forum.kirupa.com/u/The_Vulcan)\
**Post date:** [July 26, 2003, 2:37am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/1 "2003-07-26T02:37:03Z")

</div>

Question 1

on (press, release) {  
button1.onRelease = function() {  
\_root.gotoAndPlay(“scene 2”, 1);  
};  
}

I have the \_root with a sliding menu. In the sliding menu I have buttons. I want the buttons to change scenes, however the buttons only seem to function as long as my request is in within the same scene.

ex:  
gotoAndPlay(“frame 10”);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 2:39am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/2 "2003-07-26T02:39:26Z")

</div>

Do you mean the buttons in your sliding menu don’t work, or they buttons in a different scene?

Your code should either have the first or the second line, you should take one out because one of them goes on a keyframe and the other inside button1.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 2:43am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/3 "2003-07-26T02:43:27Z")

</div>

Question 2

onClipEvent (load) {  
xcenter = 250;  
speed = 1/10;

```
lowX = _root.box._x;;
highX = lowX - (this._width - _root.box._width);}

```

onClipEvent (enterFrame) {

```
var distance = _root._xmouse - xcenter;
_x += ( distance*speed );

```

* * *

```
if (this._x &gt;= lowX) {
	this._x = lowX;} 
else if (this._x&lt;=highX) {
	this._x = highX;}

```

* * *

}

How can I get the sliding menu only to function only when the mouse is over it ?

I have tried a number of variations of hittest but couldn’t get none to work.

* * *

if  
(hitTest( \_root.slide\_xmouse, \_root.slide\_ymouse, false) &&  
this.\_x \>= lowX) {  
this.\_x = lowX;}

else if (this.\_x\<=highX) {  
this.\_x = highX;}

* * *

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 2:47am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/4 "2003-07-26T02:47:33Z")

</div>

There are 2 ways, an easy way would be to put invisible buttons over them, one on each side. And do on(rollover) blah blah blah. But theres another way without doin that…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 2:57am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/5 "2003-07-26T02:57:52Z")

</div>

on (press, release) {  
button1.onRelease = function() {  
gotoAndPlay(“scene 2”, 1);  
};  
}

This is the script I am using for my buttons on the main time line. I have a sliding menu with more buttons on it, but they dont work.

Say I have scene 1, 2, 3, 4, 5,

on “scene 1”, I have a button to go to “scene 2”,  
on “scene 2”, I have a sliding menu.

When the sliding menu is double clicked on it becomes  
“scene 2”, “menu”.

it is on this “menu” layer that I have more buttons, the buttons will jump to different frames on that “menu” layer, but I canot get them to go to “scene 3”.

I thought it might have something to do with \_root \_parent but I couldn’t get either to make a difference.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:01am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/6 "2003-07-26T03:01:08Z")

</div>

You can’t tell the buttons to go to layers, you just have to directly tell it to go to a frame. I’m not too sure what you want to do…

Oh yea, your code should be:

[AS]  
on (press) {  
gotoAndPlay (“scene 2”, 1)  
}  
[/AS]

you shouldn’t have the other line under it (this is if the code is placed inside the button). You also don’t need both press and release because if you do one, you must do the other…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:12am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/7 "2003-07-26T03:12:50Z")

</div>

onClipEvent (load) {  
xcenter = 250;  
speed = 1/10;

```
lowX = _root.box._x;;
highX = lowX - (this._width - _root.box._width);}

```

onClipEvent (enterFrame) {

```
var distance = _root._xmouse - xcenter;
_x -= ( distance*speed );

```

* * *

button1.onRollOver = function() {  
if (this.\_x \>= lowX) {  
this.\_x = lowX;}  
else if (this.\_x\<=highX) {  
this.\_x = highX;}

* * *

}   
}

Sorry I dont know if this is what you meant, Create invisible button over the menu, then do a mouse over ?

this or any other code I have tried stop the menu from working properly. It just slides off the screen.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:18am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/8 "2003-07-26T03:18:00Z")

</div>

This is what ilyas made for me ages ago like last year 🙂

[AS]  
midScreen=Stage.width/2;  
speed=5;  
scroller.onRollOver=function(){  
this.onEnterFrame=function(){  
if (\_xmouse\>midScreen) this.\_x += speed;  
else this.\_x -= speed;  
if (this.\_x\>0) {  
this.\_x = -300;  
}  
if (this.\_x\<-300) {  
this.\_x = 0;  
}  
}  
}  
scroller.onRollOut=function(){  
delete this.onEnterFrame;  
}  
[/AS]

You don’t need any other code, just place that inside the sliding thing (with the instance named scrollbar). I havnt’ looked at your fla but i’m guessing you didn’t tell it to go back to its original position once it slides off the screen.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:18am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/9 "2003-07-26T03:18:35Z")

</div>

on (press, release) {  
button1.onRelease = function() {  
gotoAndPlay);  
};  
}

I did it this way because I found that sometimes I would have to click on a button twice, I wasn’t sure why and doing it that way solved the problem.

on (press) {  
gotoAndPlay (“scene 2”, 1)  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:21am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/10 "2003-07-26T03:21:19Z")

</div>

nope lostinbeta helped me with the sliding menu a few months ago.

it has 2 parts.

A box (mask)

and the sliding menu.

the sliding menu looks at the size of the box so it knows where its edges are and when to stop.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:22am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/11 "2003-07-26T03:22:51Z")

</div>

yea…thats what mine does. Isn’t that what you wanted?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 26, 2003, 3:26am UTC](https://forum.kirupa.com/t/2-simple-questions/26766/12 "2003-07-26T03:26:21Z")

</div>

Thanks for this

scroller.onRollOver=function(){

I will give it a go…
