PDA

View Full Version : MC question


T010
11-29-2006, 02:22 PM
Why is it that the first function does work, and the second one doesn't?
Both .onMouseDown and .onRollOver are meant to be used with movieclips as far as I know..?

_root.submenu.button1.onMouseDown = function(){
trace("button1text");
}

_root.submenu.button2.onRollOver = function(){
trace("button2text");
}

--
Okay, the problem is, when I replace onRollOver with onMouseDown, I have both those functions.
They actually do work, but now, it seems as if both those functions are activated whenever I click somewhere.
The output windows outputs both "button1text" and "button2text" even if I click just on the button1 or button 2.

Even when I click on a random place on the movie, it still outputs both the texts..
What's the problem with this?

anonymous
11-29-2006, 02:59 PM
Works for me?

Is that button2 mc present on stage when you assign it this handler?

Crimson
11-29-2006, 03:00 PM
change the code to

_root.submenu.button1.onMouseDown = function(){
trace("button1text");
};

_root.submenu.button2.onRollOver = function(){
trace("button2text");
};

T010
11-29-2006, 03:08 PM
It does trace, but 2 problems:

Both texts are traced at the same time (I click button 1, both texts are traced in output window, same for button 2)

and:

The buttons are placed inside a submenu(movieclip), which only appears when rolled over another button. The submenu DOES actually sit on stage from the start (only under other layers, so not visible for user), so the buttons are there from the start as well.

Now whenever I roll over the button(which is a movieclip) that causes the submenu to show, and I click anywhere on the stage, the texts are still being traced, even though I did not click the actual button.

anonymous
11-29-2006, 03:37 PM
onMouseDown will trigger from clicking anywhere on stage.

Attach your .fla.

T010
11-29-2006, 03:53 PM
the fla:

note that there will be about 6 more buttons to be added. (once it works properly)

anonymous
11-29-2006, 10:25 PM
Assigning button handlers on a movie clip, will override all other actions on other symbols nested within that movie clip.
You need to use a hitTest on the movie clip to trigger the submenu and only then will your button movie clips inside work as expected.

T010
11-30-2006, 10:03 AM
I tried using hitTest, but after an hour trying still no luck.
Would it be possible to help me in the right direction? Give me some help, some code ?

I tried this:

if (_root.opleidingen.hitTest(_root._xmouse,_root._ym ouse)) {
opleidingen.gotoAndPlay(2);
submenu.gotoAndPlay(2);
};

and this:

if (hitTest(_root._xmouse,_root._ymouse, false)){
trace("yes");
opleidingen.gotoAndPlay(2);
submenu.gotoAndPlay(2);

};

and some other variations, but no luck!

Mazoonist
12-01-2006, 01:07 AM
Here's an example menu. Hope it helps.