Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:09

coding question...


Poster: cpriest
Dated: Sunday September 19 2004 - 6:31:00 BST

Hey all, so I define a menuStyle and then use code like this:

with(milonic=new menuname("My Portfolios")){
style=menuStyle;
margin=style.margin;
style.subimage="/res/menu.arrow.right.gif";
style.subimagepadding="3";


The last two lines actually end up modifying the menuStyle object, which would indicate that the style=menuStyle line copies by reference the original object, how can I make it so this doesn't happen?

Specifically I want to modify only the style for this object, but start with the settings from 'menuStyle'.

Thanks!


Poster: Andy
Dated: Sunday September 19 2004 - 10:40:30 BST

Hi,

Doing style=menuStyle will just make a new reference to the menuStyle object, it won't actually copy it.

If you need to copy an object you can use the copyOf() function that is included with the Milonic DHTML Menu, like this:

Code:
style = new copyOf(menuStyle);


So your code will be something like this:

Code:

with(milonic=new menuname("My Portfolios")){
style=new copyOf(menuStyle);
margin=style.margin;
style.subimage="/res/menu.arrow.right.gif";
style.subimagepadding="3";



Hope this helps
Andy


Poster: cpriest
Dated: Sunday September 19 2004 - 17:32:22 BST

It does, thank you!