Help needed: Nested mc controlled by mouse position
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:
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. I`m totally confused and I can`t 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
didn`t know or I would have never thought about. That`s why I`m here.
is this the effect you were looking for? (see attached fla)
everything is done in code on the actionscript layer. I made a big green sensor clip just so you could see it - you could set it's alpha to 0 or the same code would work with a bunch of "is the mouse here and here" code like you have currently.
sensor_mc is just a simple movieclip with a green rectange in it, when you rollover it with the cursor the hitTest becomes true and it makes the grapher_mc play with nextFrame, when you roll off it plays backwards with prevFrame
If you are just reversing the direction of a tween or animation you shouldn't have to remake the animation in reverse, play it in reverse with repeated prevFrames
It is also a "best practice" to add instance names to objects on the stage and program them from a keyframe on an actionscript layer instead of attaching code to an instance of that item on the stage.
In fact I posted this question on other forums too. From the other ones it was only one working, but you gave me the best solution. Definately I have to learn ActionScript better! It was so simple! ...