all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Scrolling Menu


Scrolling Menu Mister Peanut
11/28/2006 11:32:48 PM
flash actionscript: If anyone could tell me what's wron with this code, I would really appreciate
it. I think it should work, but it doesn't work exactly how I think it should.
I have a scrolling movie clip menu behind a mask_mc. The buttons on the menu,
when pressed, each load a movie into an flv video player. This all works fine,
except when I try to make the menu function when the mouse rolls over the menu,
and disabled when I roll off. As I have it now, the menu starts scrolling when
I roll the mouse over, but when I roll off, it still scrolls. Also, after I
put my scrollMe function in, the buttons no longer work in the menu.

Here is my code


function scrollMe(){

_root.onEnterFrame = function() {
if (menu_mc._x >= 115 && menu_mc._x <= 860) {
var newX = menu_mc._x+(0.5*1300-_root._xmouse)/10 ; //Stage.width-_root
1300 = half of 1300 is centre point of scroll action.
if ( newX < 115 ) newX = 115 ;//115 adjusts the right side of clip
if ( newX > 860 ) newX = 860 ;//860 adjusts the left side of clip
menu_mc._x = newX ;
};
};
}

mask_mc.onRollOver = function(){
scrollMe();
}
mask_mc.onRollOut = function(){
scrollMe.stop();
}


Please, any help.

Cheers,

P
Re: Scrolling Menu kglad
11/29/2006 2:47:49 AM
scrollMe.stop() does not stop your rollOver handler from calling scrollMe().
if scrollMe were a timeline, then scrollMe.stop() would cause the playhead to
stop.

and once you attach a rollOver handler to mask_mc, you probably are preventing
your menu from detecting mouse events because they are intercepted by mask_mc.
Re: Scrolling Menu Mister Peanut
11/29/2006 5:11:49 PM
scrollMe.stop() does not stop your rollOver handler from calling scrollMe().
if scrollMe were a timeline, then scrollMe.stop() would cause the playhead to
stop.

Can you give me any clue as to what I should use? I am lost on this. I don't
know where to go from here.

and once you attach a rollOver handler to mask_mc, you probably are preventing
your menu from detecting mouse events because they are intercepted by mask_mc.

would a listener work if I tried to detect the x&y mouse positions in relation
to the mask_mc, and not directly reference it?

Cheers,

P
Re: Scrolling Menu clbeech
11/29/2006 5:31:58 PM
kglad, agreed. Also there seem to be several other items within this code that
may be causing the eratic behavior. The button calls should definately not be
calling on the mask_mc, and should be associated with their individual buttons
within the menu_mc. You do not need the 'scrollMe' function in order to stop
the action of an onEnterFrame event, and the call does not have to be
associated with _root. I am going to assume that you have other onRollOver and
onRelease event controls attached to the buttons with the menu_mc, directed at
loading your video player files. But I am also not understanding how the
menu_mc is set into a scrolling action, I'm wondering if you have this an a
tween or other code that is causing this action, because the code that you have
here doesn't include anything to control this type of functionality, and only
seems to be concerned with 're-centering' the menu_mc clip. Perhaps this is
not a continuously scrolling clip, but is scrolled through button actions
(left, right) ?? However, the need to stop the clip form scrolling, indicates
that it is in constant motion. That being the case, I wonder how your
achieving this? And if so, then why does the clip 're-center' after reaching
the limits, rather than starting again from the intital point to the left? OR
duplicating the MC and running in series? Sorry for all of the question and
speculations, it just is difficult to understand the purpose in the structure
of this code. However, all this being said ...

First thing, ace the use of _root, in both the onEnterFrame event and the call
to _xmouse they are not necessary and can cause problems.

Second, the operation of the scrolling menu_mc should be within a onEnterFrame
event also (I'm assuming this) therefore by calling _root.onEnterFrame, they
maybe conflicting, and both of these actions can be controlled wihtin the same
event call.

Next, it you must contain the onEnterFrame event within the scrollMe function.
the call to halt the scroll should be at least be attached to menu_mc (as kglad
mentioned) vs mask_mc.

Finally, (for now) onEnterFrame events are controlled by calling "
onEnterFrame = null; " OR if within a function by calling "
this.scrollMe.onEnterFrame = null; " or something to that effect depending on
the SWFs structure and path to the function. And when your ready to restart
the event by calling the scrollMe function, or resuming the play() call on the
timeline at that particular frame.

Hope this helps, knowing a little more about the rest of your code structure
would help with debugging.
Re: Scrolling Menu Mister Peanut
11/29/2006 6:10:46 PM
Kglad, Clbeech,

I really appreciate the replies; thanks for taking the time.

Here is my file, so you can see that there is no tween, and the mouse position
controls the scroll. I have to read over your reply more carefully before I
can respond. Here are two links, so you can see it working with the video.

http://209.139.204.44/VanAsepSite/Scroller.fla
http://209.139.204.44/VanAsepSite/Scroller.swf

Will reply soon...
Re: Scrolling Menu clbeech
11/29/2006 7:48:50 PM
Mr. P, that's great!! been working on it, don't have a lot of time now, but
replacing the stop() action with "onEnterFrame = null;" does work. But
somethings wrong with the filmstrip_mc, first of all it was a button symbol so
it was reading the whole thing as one big button. but after doing a few
things, I still couldn't get it to read the 'image' buttons. It seems that the
MC needs to be re-built but I'm not sure how just yet, I may be able to spend
more time on it later.

The mask should make no difference, for some reson something is screwed up
there, not sure what yet, try re-building from the jpg ground up even positions
the buttons individually, not sure, but somethings wierd there. All for now
Re: Scrolling Menu Mister Peanut
11/29/2006 10:01:23 PM
Check this out:

When I take out the scrollMe function, and the onRollOver function, the
buttons work. THis is what works (albeit, I cannot get my menu to stop
scrolling when the mouse is not over it), but this at lease retains the
functions of the buttons.

It seems I cannot have one without the other with the code I am using.

_root.onEnterFrame = function() {
if (menu_mc._x >= 115 && menu_mc._x <= 860) {
var newX = menu_mc._x+(0.5*1300-_root._xmouse)/10 ; //Stage.width-_root
1300 = half of 1300 is centre point of scroll action.
if ( newX < 115 ) newX = 115 ;//115 adjusts the right side of clip
if ( newX > 860 ) newX = 860 ;//860 adjusts the left side of clip
menu_mc._x = newX ;
};
};

Cheers, I owe you a beer,

P
Re: Scrolling Menu clbeech
11/29/2006 11:06:43 PM
Well, i'll-b-darn, that's wierd. I was running into a problem where I couldn't
get the buttons to function, even when taking things apart and rebuilding the
menu_mc, for some reason they weren't reading, huh? glad you got it working
though.

You could contain the "if" statement within another "if" condition to control
the scrolling. like ...

onEnterFrame = function() {

if(_xmouse > [something min] && _xmouse < [something max] && _ymouse <
[something min] && _ymouse >[something max] ) {

if (menu_mc._x >= 115 && menu_mc._x <= 860) {
var newX = menu_mc._x+(0.5*1300-_xmouse)/10 ;
if ( newX < 115 ) newX = 115 ;//115 adjusts the right side of clip
if ( newX > 860 ) newX = 860 ;//860 adjusts the left side of clip
menu_mc._x = newX ;
}

}
}

this works, I tried it. the [somethings] are the min/max coordinates of the
mask_mc clip! i've messed around with the stuff so my coordinates will be
different than yours, use whatever your mask reads at.

see whatcha think.
Re: Scrolling Menu Mister Peanut
11/29/2006 11:37:51 PM
Hey, thanks, cbeech. I was thinking that this should work, but I can't get my
mind around why it isn't.

The buttons work, unfortunately, scrolling doesn't. Any ideas? Somehow, this
other if statement is killing off my scrolling function...
I have used these coordinates for my onEnterFrame event.

onEnterFrame = function() {

if(_xmouse > 530 && _xmouse < 780 && _ymouse < 340 && _ymouse >420 ) {

if (menu_mc._x >= 115 && menu_mc._x <= 860) {
var newX = menu_mc._x+(0.5*1300-_xmouse)/10 ;
if ( newX < 115 ) newX = 115 ;//115 adjusts the right side of clip
if ( newX > 860 ) newX = 860 ;//860 adjusts the left side of clip
menu_mc._x = newX ;
}
}
}

Re: Scrolling Menu Mister Peanut
11/29/2006 11:38:55 PM
Re: Scrolling Menu clbeech
11/30/2006 2:12:29 AM
Hey Mr. P, I'm not sure why it's not functioning here? The coordinates seem
close to the original postion that I saw (I can't be sure since I changed some
things) did you change the fillmstrip MC to a graphic or MovieClip as opposed
to it remaining a button? Only thing I can think of at the moment.

As for _root, yes it can have an adverse effect on functionality, and there
really isn't any reason to use it, unless your call through multiple clips
backward many levels deep, or from loaded SWFs or MCs to touch a function on a
main timeline from a dynamic load, or tracking depths, or something like that.

The code's looking cleaner. One other thing of note, you may want to think
about setting up an array to house the calling info to your RND clip functions,
but this would be extranious and things are functioning just fine. But with an
array you could eliminate all of the "if's" to one call. you would do this like
so ...

var CLIParray:Array = new Array("Charlene.flv", "Corrina.flv", "Gabriel.flv",
.... and so on); // then call...

ns.play(CLIParray[myVideo] -1); // subtract 1 because arrays are 0 based

... and that's it, done ! no more 'if's'

Just something for ya ; )
All for now, I'll think about the x/y read problem.


Re: Scrolling Menu Mister Peanut
11/30/2006 6:11:46 PM
clbeech, you are a godsend. I owe you bigtime.

Here is where I'm at:

It is puzzling... I originally tried an onEnterFrame like you have suggested
with another if statement to detect the mouse position, and every time, it
removes the functions of the buttons. My problem always goes one of two ways:

I get the scroller to work, but the buttons don't

or

the buttons work, but the scroller doesn't.

In my mind, the code makes perfect sense, but it just doesn't work. I will
repost this fla and swf so hopefully you can see what is going wrong.

http://209.139.204.44/VanAsepSite/Scroller1.fla
http://209.139.204.44/VanAsepSite/Scroller.swf
Re: Scrolling Menu clbeech
11/30/2006 6:28:12 PM
got it Mr.P!!!!! switch the carrots for the _ymouse, they're reversed!

Re: Scrolling Menu Mister Peanut
11/30/2006 6:36:10 PM
* tears of joy*

Thanks, man.

AWESOME!!

If I ever get to the point where I can help you.....

Re: Scrolling Menu clbeech
11/30/2006 7:05:55 PM
My pleasure, Mr. P, glad I could help!

AddThis Social Bookmark Button