Help needed: Nested mc controlled by mouse position

[SIZE=3][FONT=Arial]Please help me with this if you can:

in root i have a MC named mc0; nested within it is another MC named mc1. Both have “stop();” in the first frame, but only the second (the nested one) contains an animation, in two parts: first part is from frame 1 to 10 and the second one (the reverse) from 11 to 20. I want mc1 to play the first part when the mouse enters a certain area, and the second one when the mouse exits the area. This is the main idea.

The only way that worked it was when I made two movie clips with the two parts of the animation (i split the nested movie in two mcs), and put them in m0, one in the second frame, one in the third; the first frame of m0 was stopped. So, for this, i put the following AS on mc0:

onClipEvent (enterFrame) {
if (_root._xmouse > 156 && _root._ymouse > 416) {
this.gotoAndStop(2);
}
else{
this.gotoAndStop(3);
}
}

It works like this, but I need the animation to be in only one mc (mc1), that I`m gonna nest in different parts of the main movie.

So I thought that the best for my needs would be to use something like: mc0 contains mc1, and on mc1 put this AS in the first frame:

stop;
onEnterFrame = function(){
if (_root._xmouse > 156 && _root._ymouse > 416) {
gotoAndPlay(nextFrame);
}
}

so, when mouse enters the defined area, mc1 should play (?) until it reaches frame 10 where I have another script:

onEnterFrame = function(){
if (_root._xmouse > 156 && _root._ymouse > 416) {
stop;
}
else{
gotoAndPlay(nextFrame);
}
}

that means that if the mouse stays in the area, the animation stops on frame 10. if the mouse leave the area, it should advance (with the reverse animation in fact), until it reaches frame 20, that is a keyframe with:

gotoAndStop(1);

It doesn`t work.

In fact I tried many other versions, some of them stop on frame 2, some of them just play the whole animation from 1 to 20 without any stop and without any concern of the position of my mouse. Im totally confused and I cant explain better that this.

I must admit that I`m a beginner in AS, and it might be something obvious for an advanced user that i

didnt know or I would have never thought about. Thats why I`m here.

So help me if you can.
Thank you,[/FONT][/SIZE]


myMovieClip.onEnterFrame = function(){
	if(_xmouse > 156 && _ymouse > 416){
		if(this._currentframe < this._totalframes){
			this.gotoAndStop(this._currentframe+1);
		}
	}else{
		if(this._currentframe > 1){
			this.gotoAndStop(this._currentframe-1);
		}
	}
}

The code doesnt work, I tryed to adapt it, didnt succeed. But I recieved another answer, on other forum, that solved the problem. I attach the FLA here.

Thank you for reply.

Actually, they’re just similar with each other.
And I just adopted from your code.


_root.grapher_mc.onEnterFrame = function(){
    if(_xmouse > 156 && _ymouse > 416){
        this.gotoAndStop(this._currentframe+1);
    }else{
         this.gotoAndStop(this._currentframe-1);
    }
}

same procedures but different method.

And as for your title on this thread it says,
“help needed: Nested mc controlled by mouse position

anyways, it’ll also work just like your new script, as in:


_root.sensor_mc.onEnterFrame = function(){
    if(this.hitTest(_root._xmouse, _root._ymouse, true)){
        _root.grapher_mc.gotoAndStop(this._currentframe+1);
    }else{
        _root.grapher_mc.gotoAndStop(this._currentframe-1);
    }
}

since your fine with your new code, It’ll be okay to continue with that. :wink:

You`re right, they go in the same way.
Thanks for help.