You are not logged in.

1

Thursday, September 25th 2014, 1:34pm

click, onover, onout

this code work properly
after click image changed

Source code

1
<layer name="menubar" keep="true" type="container" align="leftbottom" width="50" height="100%" x="0" y="0" bgalpha="0.7" bgcolor="0xFFFFFF">		<layer name="menubutton" url="%SWFPATH%/images/menu-icon.png" align="lefttop" x="2" y="5" 			onclick="set(layer[menubutton].url,'%SWFPATH%/images/cross.png');"		/></layer>

code below
onover work properly
but onclick responce after first click dont work
(image dont changed)
after second click and further image changed

Source code

1
<layer name="menubar" keep="true" type="container" align="leftbottom" width="50" height="100%" x="0" y="0" bgalpha="0.7" bgcolor="0xFFFFFF">		<layer name="menubutton" url="%SWFPATH%/images/menu-icon.png" align="lefttop" x="2" y="5" 			onclick="set(layer[menubutton].url,'%SWFPATH%/images/cross.png');"			onover="set(layer[menubutton].url,'%SWFPATH%/images/menu-icon-over.jpg')"		/></layer>



why such behavior
and how too make that work properly

and how too properly work with buttons in separate image files

2

Saturday, September 27th 2014, 8:59am

Hi,

I'm not fully sure yet what you mean and if you're asking for Flash or HTML5, but there is one thing to consider:

When replacing an image the browser can lose it's 'mouse' state - e.g. when the mouse moves over an element, the browsers send an over event, then the image will be removed and replaced, now the new image doesn't have an 'over' state and so the browser isn't sending an 'out' event when mouse moves out of the element.

The best possibilities to avoid such problems, is to use either sprite-sheets and the crop settings or several elements and toogling their visibility (e.g. several children layer elements with enabled=false and dynamically change their visible setting).

This would also avoid the need for reloading or waiting when an image gets replaced.

Best regards,
Klaus