Sliding Menus - Step Seven: Placing a Button on Stage
Posted by : PhilS on Jul 29, 2008
The last thing is to place a button on Stage and set the ActionScript so that the Movie Clip moves when you roll over or click the button. You will either need to either create a new button and place it on Stage or drag a button out of the common button library. Either:
Create your own Button and place it on Stage
Or: go to Window - Other Panels - Common Libraries - Buttons and drag a button onto the Main Stage.
My Button: ![][1]Select the new: Button
- If the Actions Panel is closed, open it: Window - Actions (F9)
Type (or copy & paste) the following actions:
*on (rollOver) { yTargetMC = 200; }* **Note**: The target number must be different to the number in frame 1 otherwise the Movie Clip will not move. Change the target number to a number that suits the position that you want the Movie Clip to stop at. As an alternative make the Movie Clip move *on (release)* like this: *on (release) { yTargetMC = 200; }*Create as many other buttons as you want stop positions: Create more Buttons
I created one more button: ![][2]Add the above code to you new buttons but change the target position. Like this:
*on (release) { yTargetMC = -600; }*

1 comment
Add comment
Saulgarber
It's wanderful, I made it with pictures and it work nice.
But I'm trying to make the image zoom and move in different places with two buttons and it goes to the same place (X & Y)... I tried with this:
Button 1
on (rollOver) { yTargetMC = 80; xTargetMC = 80; _xscaleMC = 400; }
Button 2
on (rollOver) { yTargetMC = 60; xTargetMC = 60; }
Movie Clip
*onClipEvent (enterFrame) { yMC = getProperty(_root.MC, _y); moveMC = _root.yTargetMC - yMC; setProperty(_root.MC, _y, yMC + (moveMC/10)); }
onClipEvent (enterFrame) { xMC = getProperty(_root.MC, _x); moveMC = _root.xTargetMC - xMC; setProperty(_root.MC, _x, xMC + (moveMC/10)); }
onClipEvent (enterFrame) { xMC = getProperty(_root.MC, _xscale); scaleMC = _root.xTargetMC - xMC; setProperty(_root.MC, _xscale, xMC + (scaleMC/40)); }
onClipEvent (enterFrame) { yMC = getProperty(_root.MC, _yscale); scaleMC = _root.yTargetMC - yMC; setProperty(_root.MC, _yscale, yMC + (scaleMC/40)); }*
It didn't work fine... Could you help me?
Tx Saul
#  /  PM  /  posted on Apr 15, 2011