O.K., so far so good. But now let's make the movie a bit
more exciting. Next you're going to make the buttons move
too:
On the main time line select all of your buttons and convert
them into a single movie clip. Give this movie clip the
instance name buttons. Because we've now changed the file
path from the buttons to the controlMC we now need to add
_root. to the front of the second line of code on each button.
The first button, for example, now looks like this:
Now you need to alter the script on the key frames of the
controlMC. The frames now look like this:
Key Frame 2:
//These are the variables that set the destination
of our changes
_root.pagesTargetX = 50;
_root.buttonsTargetX = 130;
//This sends the appropriate MC into action
_root.motionScript.gotoAndPlay ("change");
Key Frame 3:
//These are the variables that set the destination
of our changes
_root.pagesTargetX = -170;
_root.buttonsTargetX = 80;
//This sends the appropriate MC into action
_root.motionScript.gotoAndPlay ("change");
Key Frame 4:
//These are the variables that set the destination
of our changes
_root.pagesTargetX = -390;
_root.buttonsTargetX = 30;
//This sends the appropriate MC into action
_root.motionScript.gotoAndPlay ("change");
As you can see all you've done is add a new variable buttonsTargetX
to the main timeline. Now you've done that you need to add
script to the second keyframe of the script layer of the
motionScript movie clip. It's virtually identical to the
script in step one, so if you can't remember what it does,
read the explanation on the previous page. It now looks
like this:
Key Frame 2:
//This controls the x position of the pages
gap = _root.pagesTargetX - _root.pages._x;
_root.pages._x = _root.pages._x + (gap / 3);
//This controls the x position of the buttons
gap = _root.buttonsTargetX - _root.buttons._x;
_root.buttons._x = _root.buttons._x + (gap / 6);
Notice that I've used the variable gap twice, I've done
this to emphasise the similarity of the scripts. What's
happening here is that gap is assigned a value, and the
script acts on it once, altering the x position of the pages
movie clip. It's then reassigned a different value and the
script acts on it, altering the x position of the buttons
movie clip. The framehead then passes onto frame three,
which, if you remember, sends the framehead back to frame
two, and the process runs again.
That's step two complete! Test your movie, and your buttons
should be moving too.