I was wondering what the best way is to play a movie clip while dragging a button inside a separate movie clip.
Example: I’m creating a children’s book in Flash form. Some childrens’ books have movement using a pull tab on the side of the page. I have created two things for one of these pages:
A) The pull tab movie clip consisting of a button inside of it. Its code is as follows:
on (press) {
startDrag(toggleDrag2,false,596.5,118.0,666.5,118.0);
}
on (release) {
stopDrag();
}
This way (and it works), the pull tab cannot be dragged along the y axis, and its movement along the x axis is restricted.
B) A movie clip with a symbol in it that has a motion tween, 75 frames, a stop action and key frame on each of the 75 frames.
There is exactly 75 x coordinates the pull tab can be dragged along (its instance name is toggleDrag2 and the movie clip instance name is Flying Violin).
What I’m not sure how to do is make the Flying Violin move with the pull tab. Not literally along the the x-axis, but with each increase in the x axis of the pull tab, I want the FlyingViolin to play one frame, then stop and wait for the x-axis to increase or decrease. If it decreases, the FlyingViolin movieclip moves back a frame and stops.
Here is the code I came up for the FlyingViolin movie clip:
onClipEvent(enterFrame){
var _x1 = _root.toggleDrag2._x;
if(_root.toggleDrag2._x>_x1)
_root.FlyingViolin.play();
if(_root.toggleDrag2._x<_x1)
_root.FlyingViolin.gotoAndPlay(_currentFrame-1);
}
What I wanted to do was assign a new variable the x value of the pull tab (toggleDrag2), allow the x value to increase, and when it increases any amount, the ActionScript checks to see if toggleDrag2’s x value is now greater or less than it was before, and if it is, the FlyingViolin movie clip either plays or decreases a frame (_currentFrame-1).
Did I do this right?
-Galen