# RollOver Menu?

**URL:** <https://forum.kirupa.com/t/rollover-menu/187981>\
**Category:** flash\
**Created:** [May 3, 2006, 3:26pm UTC](https://forum.kirupa.com/t/rollover-menu/187981 "2006-05-03T15:26:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxskuk](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@maxskuk](https://forum.kirupa.com/u/maxskuk)\
**Post date:** [May 3, 2006, 3:26pm UTC](https://forum.kirupa.com/t/rollover-menu/187981/1 "2006-05-03T15:26:57Z")

</div>

hi everybody.  
just created a simple rollover menu with elastic effect, (no Macromedia, just Ming and PHP)  
well. i can’t make it disappear on RollOut…(check the MovieClip.prototype.removeMenu in the code)  
lazy or dumb, the choice is up to you! any suggestions?  
max.

the code:  
"  
function createSquare(target, targetW, targetH, lineW, lineAlpha, lineColor, fillColor, fillAlpha, CurveRadius) {  
targetW = targetW - lineW;  
targetH = targetH - lineW;  
with (target) {  
lineStyle(lineW, parseInt(lineColor, 16), lineAlpha);  
moveTo(CurveRadius + lineW, 0);  
beginFill(parseInt(fillColor, 16), fillAlpha);  
lineTo(CurveRadius + lineW, 0);  
curveTo(0 + lineW, 0, 0 + lineW, CurveRadius);  
lineTo(0 + lineW, targetH - CurveRadius);  
curveTo(0 + lineW, targetH, CurveRadius + lineW, targetH);  
lineTo(targetW - CurveRadius, targetH);  
curveTo(targetW, targetH, targetW, targetH - CurveRadius);  
lineTo(targetW, CurveRadius);  
curveTo(targetW, 0, targetW - CurveRadius, 0);  
lineTo(CurveRadius + lineW, 0);  
endFill();  
}  
}

Stage.width = SW ;  
Stage.height = SH;

MovieClip.prototype.elastic\_button = function (target, destination)  
{  
var spring = 0.2;  
var friction = 0.9;  
var velocity = 0;  
var acceleration = 0;  
target.onEnterFrame = function ()  
{  
acceleration = (destination - this.\_y) \* spring;  
velocity = velocity + acceleration;  
velocity = velocity \* friction;  
target.\_y = target.\_y + velocity;  
};  
};

wordlist = new Array ();  
phrase = ‘cat1|cat2|cat3|cat4’;  
wordlist = phrase.split(’|’);  
num = wordlist.length;

buttonWidth = SW/num;  
buttonHeight = 20;  
this.createEmptyMovieClip(‘button’, 1);  
with (button)  
{  
createSquare(button, buttonWidth, buttonHeight, 2, 100, ‘0xFFFFFF’, ‘0xF5B723’, 100, 0);

}  
button.\_x=50;  
button.\_y=50;  
button.createTextField(‘buttonText’, button.depth, 0, 0, buttonWidth, buttonHeight);  
var buttonText = button[‘buttonText’];  
var myFormat = new TextFormat ();  
myFormat.font = ‘Luxi Sans’;  
myFormat.size = 14;  
myFormat.leftMargin = 0;  
myFormat.align = ‘center’;  
myFormat.leading = 0;  
myFormat.color = 0xFFFFFF;  
buttonText.border = false;  
buttonText.borderColor = 0x000000;  
buttonText.embedFonts = false;  
buttonText.editable = false;  
buttonText.selectable = false;  
buttonText.antiAliasType = ‘advanced’;  
buttonText.\_quality = ‘HIGH’;  
buttonText.html = true;  
buttonText.htmlText = ‘CATEGORIE’;  
buttonText.setTextFormat(myFormat);

button.onPress=function()  
{  
removeMenu(button,num);  
status.htmlText = ‘onPress–\>remove’;  
status.setTextFormat(myFormat);  
};  
button.onRelease=function()  
{  
createMenu(button,num);  
status.htmlText = ‘onRelease–\>create’;  
status.setTextFormat(myFormat);  
};

MovieClip.prototype.createMenu = function (target, n)  
{  
this.onEnterFrame=function()  
{  
i = 0;  
while (i \< n)  
{  
buttons = [];  
title = ‘button’+i;

```
    buttons* = target.duplicatemovieclip(title, num + i);
    buttons*._x=target._x;            
    elastic_button(buttons*,target._height+(target._y+(target._height*i)));
    
    buttons*.createTextField('mybuttonText', (n + i) * n, 0, 0, buttonWidth, buttonHeight);
    var mybuttonText = buttons*['mybuttonText'];
    mybuttonText.embedFonts = false;
    mybuttonText.editable = false;
    mybuttonText.selectable = false;
    mybuttonText.antiAliasType = 'advanced';
    mybuttonText._quality = 'HIGH';
    mybuttonText.html = true;
    mybuttonText.htmlText = wordlist*;
    mybuttonText.setTextFormat(myFormat);
        
    i++;
    }
};    

```

};  
MovieClip.prototype.removeMenu = function (target, n)  
{  
this.onEnterFrame=function()  
{  
i = 0;  
while (i \< n)  
{  
buttons = [];  
removeMovieClip(buttons\*);  
i++;  
}  
};  
};  
this.createTextField(‘status’,2, 20, 20, 250,20);  
var status = this[‘status’];  
status.embedFonts = false;  
status.editable = false;  
status.selectable = false;  
status.antiAliasType = ‘advanced’;  
status.\_quality = ‘HIGH’;  
status.html = true;  
"  
Thanx!  
Max
