Moving mc

hi

in the main movie i have three bottons, and a hand pointing to the home button. I want to make this hand to go to the button presses later, and then move again, (without going back to the inictial point) to the third button. How do I do this?
I searched in the forum, but I didn´t know exactly witch word to use for this action

Any help?

Thx

I know how to do it, but it involves invisible movieclips and hitTest and all those things. It would be quite long to explain. I’m sure there is a better way to do it.

I started answering your question and ran into some questions for you. Are the buttons going up and down, or from left to right? Do you want the hand to just change positions in a blinking fashion, or move into position? Your hand’s a movieClip, right?

yes, it a mc, the buttons go from left to right and I´d like the hand to move into position.

There’s a few ways to do this, if I am thinking what you are thinking. I’m not sure what Voetsjoeba is thinking of, but it’s not the same as me - I think (I gotta quit thinking). If you want it to move into position, we will use an easing formula and change the variable with the buttons.

Anyho-
Give your hand movieClip the instance name of ‘hand’.
Put that movieClip over the home button where you want it to be (so there is a _y coordinate) . If I understand, all you want to do is change the _x postition of the ‘hand’. So, on your buttons, with your existing actions - put the action:
[AS]
on(rollOver){
_root.endx=200;
//the 200 is wherever you want the hand to end up for each
//button and must be different for each button, obviously
}
[/AS]
Then on your movieClip (hand), put this:
[AS]
onClipEvent(load){
_x=20;
_y=20;
//change these numbers to wherever the movieClip is on the
//stage now, where you want it to begin.
speed=5;
//speed of the movement
}
onClipEvent(enterFrame){
_x += (_root.endx-_x)/speed;
}
[/AS]
I use this exact thing for a little triangle on one of my sites that points to a button when you rollover it. If the hand starts in a strange place (because I’m not sure, but I think endx will be zero without defining it first) - just put _root.endx=200 in the load part of the actionScript.

That’s what I do anyway. I know of a couple different ways like adding this to a button:
[AS]
on(rollOver){
_root.hand._y=200;
}
[/AS]
But that isn’t as fun. I ramble a lot so I don’t know if this made sense, if not, let me know I’ll make a fla for you.
-Freddy

I’m just gonna explain my method here, I’m sure there are better ways to do this, but anyway. The hand should already be on the y position you want to use.

  1. Create a new, empty movieclip (CTRL+F8), give it any name and hit OK. Return to the stage by pressing the link on the bar right above the stage.

  2. Create a new layer. Open your library (F11) and drag the movieclip you just created from the library to the stage ( doesn’t matter where ) on the layer you just created.

  3. Apply the following actionscript to it (if the hand and the buttons are on the main timeline):

[AS]
onClipEvent(load){
_root.targX = _root.button1._x;
_root.invisbox1._visible = false;
_root.invisbox2._visible = false;
_root.invisbox3._visible = false;
_root.startDrag(_root.drag, true);
}
onClipEvent(enterFrame){
_root.hand._x = _root.targX - (_root.targX - _root.hand._x)/1.2;
if(_root.drag.hitTest(_root.invisbox1)){
_root.targX = _root.button1._x;
}
if(_root.drag.hitTest(_root.invisbox2)){
_root.targX = _root.button2._x;
}
if(_root.drag.hitTest(_root.invisbox3)){
_root.targX = _root.button3._x;
}
}
[/AS]

  1. Create a new layer, call it invisbuttons or something, and create seperate boxes which cover the buttons, as if they were the hit state. Make every box a seperate movieclip, and give them the instance names invisbox1, invisbox2 and invisbox3.

  2. Create another new empty movieclip (CTRL+F8 again), return to the stage and drag it from the library to the stage, as described before. Give it the instance name [COLOR=BLUE]drag[/COLOR]

That should do it. I might’ve forgotten something though, I don’t have flash here.

Just saw Fred’s answer, I used that method once too, but I turned out not working for me, so I created the inv buttons method. I’m trying to remember WHY it didn’t work for me …

Yeah, I don’t know why either, it works for me fine. I mean basically it’s the same thing, I’m just putting the action script in the ‘hand’ itself and using the buttons that are already existing.

Both methods will work well…(-:

Yeah, I know yours will work. That’s why I was wondering, I used the same method once, and it didn’t work … But when I see it now, I know it will work …

Anyway, I was still a total newbie then and I was trying out some code, so I probably did something stupid that makes no sense …
Everyone, use Freddythunder’s :stuck_out_tongue:

thanks guys

i´ll tray that soon and I´ll let you know if worked.

Yeah, I still make little, miniscule, mondane, noobian mistakes (to this day!!) everytime I touch a keyboard!! I’ll forget a period in a statement and It’ll drive me nuts for hours!! I still feel like a noobee!! :stuck_out_tongue:

thanks for the help guys
it worked

I´m going to ask one more thing…
since the hand, that is a mc, is going to move to the button position, then would be nice to have it change to something or make a movement. Can I make the hand to play when reaches a button position?

Well, there is. I had to try it first, but this will work. There’s a couple different ways you can do this too. One is, double click the hand and make your animation. Put a stop(); in the first frame. then add this to the movieClip’s AS:
[AS]
onClipEvent(enterFrame){
_x += (_root.endx-_x)/speed;
//above code you already have if using my variation
if (_x==stopOne or _x==stopTwo or _x==stopThree){
this.play();
}
[/AS]
stopOne, stopTwo, stopThree are the three endx numbers you used. This will play the animation regaurdless of any stop()s you have in it until it moves off of those spots.

The other way would be to make a three seperate animations in movieClips with empty first frames and call them by instance name when the hand gets there like:
[AS]
onClipEvent(enterFrame){
_x += (_root.endx-_x)/speed;
//above code you already have if using my variation
if (_x==stopOne){
_root.animationMovieClipOverFirstButton.gotoAndPlay(2);
}
if (_x==stopTwo){
_root.animationMovieClipOverSecondButton.gotoAndPlay(2);
}
//etc etc
[/AS]

Sorry my posts are running long today…[SIZE=1]I’m lonely…[/SIZE]

thanks very much

nice hints