First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Aaron Ham

Now this is where the fun begins.

Creating the code

Well, 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)));
» Level Intermediate

Added: 2002-02-19
Rating: 7.99 Votes: 186
(10 being the highest)
» Author
I'm a freelance web developer and designer. Although I specialize in networking (you know, Cisco routers, servers, etc), I also dabble with programming and right-brained creativity.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.