alert This appears to be a flash file, you cannot see a preview because flash player is no longer supoorted in browsers, but you can still download the file to study it's source code.
You can open/play the swf file with Flash Player exe
user jmalek
jmalek (7)

Image Menu v2

Modified version of the previous, the menu now has functional links. Much thanks to sanjum for help with the script.

To modify urls, simply open imagemenu.as file and edit the "URL" array after [var mcPaths = ...]

15577 downloads, 64631 views
Download (1.30 MB)

Comments

You need to login to post a comment.

user PorcoNu
PorcoNu 13 years ago

some one can post all code here, with the places to change the urls????

user ingniko
ingniko 14 years ago

import mx.transitions.Tween;
import mx.transitions.easing.*;

function findMaxLevel(menu_no, mc_string):Number {

var maxDepth:Number = 0;
var clip:Number = 0;
var j:Number;
for (j=0; j<menu_no; j++) {
if (eval(mc_string+j).getDepth()>=maxDepth) {
maxDepth = eval(mc_string+j).getDepth();
clip = j;
}
}
return clip;
}
function setMenu(menu_no, menuStartX, widthOption, mc_string) {
var j:Number;
for (j=0; j<menu_no; j++) {
var _mc:MovieClip = new MovieClip();
_mc = this[mc_string+j];
_mc.onRollOver = function() {
var l:Number = this._name.lastIndexOf(mc_string.substr( mc_string.length-1,mc_string.length) );
var number:Number = Number(this._name.substr(l+1, 2));
var i:Number;
var tempMC:Number;
tempMC = findMaxLevel(menu_no, mc_string);
eval(mc_string+number).swapDepths(ev al(mc_string+tempMC));
var tempWidth:Number = ((menu_no*widthOption)-200)/(menu_no-1);
var tempPosX:Number = menuStartX;
for (i=0; i<menu_no; i++) {
if (i != number) {
var tw:Tween = new Tween(eval(mc_string+i), "_width", Strong.easeOut, eval(mc_string+i)._width, tempWidth, 1, true);
var tw2:Tween = new Tween(eval(mc_string+i), "_x", Strong.easeOut, eval(mc_string+i)._x, tempPosX-(widthOption-tempWidth)/2, 1, true);
tempPosX += tempWidth;
} else {
var tw:Tween = new Tween(eval(mc_string+i), "_width", Strong.easeOut, eval(mc_string+i)._width, 200, 1, true);
var tw2:Tween = new Tween(eval(mc_string+i), "_x", Strong.easeOut, eval(mc_string+i)._x, tempPosX-(widthOption-200)/2, 1, true);
tempPosX += 200;
}
}
};
_mc.onRollOut = function() {
var l:Number = this._name.lastIndexOf(mc_string.substr( mc_string.length-1,mc_string.length) );
var number:Number = Number(this._name.substr(l+1, 2));
var i:Number;
for (i=0; i<menu_no; i++) {
var tw:Tween = new Tween(eval(mc_string+i), "_width", Strong.easeOut, eval(mc_string+i)._width, widthOption, 1, true);
var tw2:Tween = new Tween(eval(mc_string+i), "_x", Strong.easeOut, eval(mc_string+i)._x, menuStartX+i*widthOption, 1, true);
}
};
_mc.onRelease = function() {
if (this._name == "mainmenu0") {
getURL('about.htm', '_self');
}
if (this._name == "mainmenu1") {
getURL('http://www.yahoo.co.uk/', '_ blank');
}
if (this._name == "mainmenu2") {
getURL('http://www.facebook.com/', ' _blank');
}
if (this._name == "mainmenu3") {
getURL('http://www.google.co.uk/', ' _blank');
}
if (this._name == "mainmenu4") {
getURL('http://www.google.co.uk/', ' _blank');
}
if (this._name == "mainmenu5") {
getURL('http://www.google.co.uk/', ' _blank');
}
};
}
}


function createRectangle(x:Number, y:Number, width:Number, height:Number, color:Number, alpha:Number, number:Number, option_name:String, txtFormat:TextFormat, mc_string):MovieClip {

var mc:MovieClip = this.createEmptyMovieClip(mc_string+numb er, this.getNextHighestDepth());
var mc_txt:TextField = mc.createTextField("menu_txt"+number, this.getNextHighestDepth(), -width/2+5, -height/2+5, width-10, height);
mc.beginFill(color);
mc.moveTo(-width/2, -height/2);
mc.lineTo(-width/2, -height/2);
mc.lineTo(width/2, -height/2);
mc.lineTo(width/2, height/2);
mc.lineTo(-width/2, height/2);
mc.endFill();
mc._x = x;//+width/2;
mc._y = y;//+height/2;
mc._alpha = alpha;
mc_txt.text = option_name;
mc_txt.selectable = false;
mc_txt.setTextFormat(txtFormat);
return mc;
}

function createMenu(numberOfOptions:Number, menuWidth:Number, menuHeight:Number, menuStartX:Number, menuStartY:Number, menuItems:Array, txtFormat:TextFormat, mc_string:String) {
var widthOption:Number = Math.floor(menuWidth/numberOfOptions);
var menuStartX:Number = menuStartX+widthOption/2;
var menu_no:Number = numberOfOptions;
var i:Number;
for (i=0; i<menu_no; i++) {
var color:Number = Math.random()*255*0xFF0000+Math.random() *255*0x00FF00+Math.random()*255*0x0000FF ;
createRectangle(menuStartX+i*widthOpt ion, menuStartY+menuHeight/2, widthOption, menuHeight, color, 100, i, menuItems[i], txtFormat, mc_string);
}
setMenu(menu_no, menuStartX, widthOption, mc_string);
}

user stylekeeper
stylekeeper 15 years ago

for linking to a specific label in your movie. i used the same code nilsy posted and just replaced it with the root path and it worked...
var j:Number;
for (j=0; j<menu_no; j++) {
var _mc:MovieClip = new MovieClip();
_mc = this[mc_string+j];
_mc.onRelease = function () {
if (this._name == "mainmenu0") {
_root.gotoAndStop("home");
}
if (this._name == "mainmenu1") {
_root.gotoAndStop("leg");
}
if (this._name == "mainmenu2") {
_root.gotoAndStop("way");
}
if (this._name == "mainmenu3") {
_root.gotoAndStop("induli");
}
if (this._name == "mainmenu4") {
_root.gotoAndStop("people");
}
if (this._name == "mainmenu5") {
_root.gotoAndStop("pics");
}
if (this._name == "mainmenu6") {
_root.gotoAndStop("contact");
}
};

user berzera
berzera 15 years ago

Hi r-land...can you send me the correct AS code, i have the same problem in the buttons, always tha same link.
[email protected]
thanks!

user r-land
r-land 15 years ago

Hi again :) Problem solved, if you need a solution code, mail me :)
buttons now work fine.

user r-land
r-land 15 years ago

yep, links suck :D if you change them through imagemenu.as, they work, but not all, only one - 5th in an array. And it works for all buttons :D It's kind a strange :)

user r-land
r-land 15 years ago

I removed Math.Floor function from line 82 of your AS code.
My thumbs were 119px and script always gave me 2px line in the end of the thumbs. And it is better to put black background, cause if you look at a preview swf here on the page, there is sometimes a 1px line coming out between thumbs. Black background solves that :)
And you definitely should work with this script more to add more dynamics to it. Width and position functions are based on mathematics and I had to understand the code completely before I could change it to work properly with my thumbs (they were really narrow and a lot of space around them).
Anyway, thanks for sharing. I'm a blogger and I would like to use your code for tutorial if you don't mind. Of course I put all the links to your profile :) Please give me to know, you can answer here or send an e-mail to [email protected]
Thank you in advance :)

user r-land
r-land 15 years ago

you know, I was looking for this script about two months ago and didn't find it. I tried to do tihs by myself but as I'm not a big professional in ActionScript - nothing came out of it :D Thanks for sharing ;)

user shekhar
shekhar 15 years ago

hey its not working

user jmpriego
jmpriego 15 years ago

How I can do, the same menu, but horizontaly??
Thanks

user aca
aca 15 years ago

How do you change the links?
in "imagemenu.as" dont change...
thanks

user FoxHound
FoxHound 15 years ago

good job!
how do you add words in the pictures?

user sinbad78
sinbad78 15 years ago

sry for spamming:
What should I do if I want to have 7 or 8 buttons?
Which part of code should I change:
Already I made 7 mc which are sliding and working - but every click leads me to undefined page.
where can I find coordinates of buttons - imagemanu.as ?

user sinbad78
sinbad78 15 years ago

How those buttons work?
I always get : undefined
What is going on ?

user treidy2003
treidy2003 15 years ago

My images are 800x600. How can I make your example larger?

user yamadie
yamadie 16 years ago

Little Changs : in imagemenu.as

find :
for (j=0; j<menu_no; j++) {
var _mc:MovieClip = new MovieClip();
_mc = this[mc_string+j];
_mc.onRelease = function () {
getURL(mcPaths[j], "_blank");
};
replace with :
for (j=0; j<menu_no; j++) {
var _mc:MovieClip = new MovieClip();
_mc = this[mc_string+j];
_mc.num = j
_mc.onRelease = function () {
getURL(mcPaths[this.num], "_blank");
};

user villitani
villitani 16 years ago

Could you possibly post the as3 version of this?

user tridi001
tridi001 16 years ago

How can i using that menu to link to a specific frame or movieClip?...

I don't want to link to a URL, how can I change the as file? Please help

user gbtrabzon
gbtrabzon 16 years ago

i just wonder how to add xml list in this fla?to get the images...

user demoche
demoche 16 years ago

How can I put a different link URL for every image?

user jinusj
jinusj 16 years ago

Hi Jmalek,
I am facing the same problem
The links are not working. I set up all the links for the menu editing the imagemenu.as file, but after cliking on the diferent images of the menu it allway return me the last url of the array.

Could you help me fix it?

Thanks

user lawless
lawless 16 years ago

hi i tried using loadMovieNum(mcPaths[j],1);
on line 26 to modify it to load and external swf...

it doesn't work any help would be greatly appreciated
thanks in advance!

user juice624
juice624 16 years ago

is there a way to add text to the images itself?

user romtania
romtania 16 years ago

I'm still having trouble using that menu to link to a specific frame or movieClip?...

I don't want to link to a URL, how can I change the as file? Please help

user dammarcos
dammarcos 16 years ago

Hi everybody, to make the links work you have to modify the line 19, of the imagemenu actionscript file, replace the links with yours and thats it,
var mcPaths = ["http://www.ffiles.com", etc........];
cheers from the other side of the world Argentina.

user Nilsy
Nilsy 16 years ago

I have found a way to make the links work

In the actionscript file under the mc_paths this script can replace what is there. you can change the links to whatever you like.


for (j=0; j<menu_no; j++) {
var _mc:MovieClip = new MovieClip();
_mc = this[mc_string+j];
_mc.onRelease = function () {
if (this._name == "mainmenu0") {
getURL('about.htm','_self');
}
if (this._name == "mainmenu1") {
getURL('http://www.yahoo.co.uk/','_ blank');
}
if (this._name == "mainmenu2") {
getURL('http://www.facebook.com/',' _blank');
}
if (this._name == "mainmenu3") {
getURL('http://www.google.co.uk/',' _blank');
}
if (this._name == "mainmenu4") {
getURL('http://www.google.co.uk/',' _blank');
}
if (this._name == "mainmenu5") {
getURL('http://www.google.co.uk/',' _blank');
}
};

I hope this helps everybody . it worked for me!

user bobocel
bobocel 17 years ago

Hey. This looks a lot like my file, but it doesn't seem to be dynamic or resizable, so I had to make sure it isn't my file. :)

You might want to check it out though as using XML will sure enhance your own files. Good luck.

user rynzco
rynzco 17 years ago

wow great work jmalek....but my question s What shall I do to use that menu to link specific frame or movieClip?...

your reply would greatly appreciated

user applegrave
applegrave 17 years ago

Hi Jmalek, I also have the same problem with the links ... What shall I do to use that great looking menu? Thx

user avyssos
avyssos 17 years ago

Hello, my name is LIA and i have the same problem.
Any solution?
Please help!!!!!
Thanks

user turha
turha 17 years ago

I forgot to say that I added a new image, so I'm workin with 5 images. I change the value of the MenuItens to 5, but it doesn't work was I posted before.

Thanks

user turha
turha 17 years ago

Hi Jmalek,

This menu it's just perfect! But i'm having a problem with it. The links are not working. I set up all the links for the menu editing the imagemenu.as file, but after cliking on the diferent images of the menu it allway return me the last url of the array.

Could you help me fix it?

Thanks