Search Tutorials
Now this is where the fun begins.Creating the codeWell, you should now have a nice line of Icons that do absolutely nothing (unless you assigned an action to the buttons). They just sit there and look like any other menu on the block. Well, it's time to give it some identity and make it move. Open the object actions for the control movie clip. The first section of code will set up some functions for us to use later. We only need these functions to be defined once, so I used the "onClipEvent (load)" action. Two functions are defined here - checkOffset(coffset) and setScale(soffset). The first function checks to see if the offset value passed to it is outside our acceptable range. If it is, then it sets the offset to the maximum or minimum value. Basically, it keeps the offset between -175 and +175 pixels. So what is the offset for? The offset is the distance between the origin point of the icon and the cursor. The second function setScale(soffset) will return the scale value of the icon in question based on the offset value. The closer the cursor gets to the icon in question, the larger the icon will grow, up to a maximum of 300%. The farther away the cursor becomes, the smaller the icon will get, to a minimum of 100%.
onClipEvent (load) {
function checkOffset (coffset) {
if (coffset<-175) {
coffset = -175;
} else if (coffset>175) {
coffset = 175;
}
return coffset;
}
function setScale (soffset) {
return 100*(3-(2*(Math.abs(soffset)/175)));
}
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|