coding question...

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
cpriest
Advanced
Advanced
Posts: 17
Joined: Mon Sep 13, 2004 6:38 pm

coding question...

Post by cpriest »

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!
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

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: Select all

style = new copyOf(menuStyle);
So your code will be something like this:

Code: Select all


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
cpriest
Advanced
Advanced
Posts: 17
Joined: Mon Sep 13, 2004 6:38 pm

Post by cpriest »

It does, thank you!
Post Reply