Featured FLA
» Author: Nitin Tikhe
» Title: Cart
» Description: This Animation Tut is a fun and useful for kids below 15 years. Watch the Flag, Doors, Stick and Horse movements.
» More by Nitin Tikhe
Featured Site
» Posted in the Flash Kit Links section
» Title: Banana Swimwear
» Description: This is a banana swim wear interactive catalog we designed and animated in Flash
This is the layer where we will add the actionscript to
make the mask drag work. The first thing to do is to add a new layer called “actionscript”,
lock all of the other layers so that you don’t move any of the elements by
mistake. On the “actionscript” layer create a new movie and call it “actionscript”,
edit this movie clip. On the first frame place a keyframe and then place one on
the 2nd frame aswell.
What this does is it sets two variables one to be equal to
“_root.xmouse” which is the x co-ordinates of the current cursor and one to
be able to the y co-ordinates. Then the “If” statement tells the navigation
movie to check if the mouse cursor is within the boundaries of the picture. I
have removed 5 pixels from the maximum value to stop the navigation movie trying
to go to keyframe 138 where there is nothing to show. If the “x_mouse” value
is within these limits then the “navigation” is told to goto and stop at the value of the “x_mouse” variable
(rounded to the nearest integer “Math.round()” ) and divided by four) You
have to divide by four to keep the number of keyframes required for the movie to
a manageable number. The same code is put into both keyframes to make the movie
run smoother . And that’s all the actionscripting you will need!
Now return to the “navigation” movie timeline, drag
an instance of the “actionscript” movie clip you just created to the
“actionscript” layer. Now if you preview the movie it will drag the mask
across the two pictures and reveal the colour one “through” the black and
white one. Make sure that the “actionscript” layer has frames inserted all
the way to the final frame of the “navigation” movie otherwise it won’t
work. Finally add a “stop” action to the first frame of the actionscript
layer to stop the “navigation” movie from playing when first loaded.