OK guys, you've managed to stump me once again.
Development platform: Win2K, IE 5.0
I have a DynLayer. I've added two Button widgets to it. I've added an event
listener to each button. The event listener for each button does the same
thing. When the button is clicked, it looks for a hidden field on a form,
reads the value from it, and changes the DynImage for the button based on
the value. This works fine. My problem is that the second button changes the
image, not on itself as intended, but on the first button. I've actually
attempted this with as many as 4 buttons, but no matter which button is
pressed, the image only changes on the first button. The behavior shows up
in both IE 5.0 and 5.5. I've included the code that causes the problem. I'd
appreciate any incite this list can offer.
<HTML><HEAD><TITLE>Tools</TITLE>
<Script language="Javascript" src="scripts/dynapi.js"></script>
<Script language="Javascript">
DynAPI.setLibraryPath('scripts/lib/');
DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.gui.label.js');
DynAPI.include('dynapi.gui.button.js');
DynAPI.include('dynapi.gui.dynimage.js');
</script>
<script language="javascript">
in_pressed = DynImage.getImage('images/toolzoomin_press.gif');
in_off = DynImage.getImage('images/toolzoomin_off.gif');
out_pressed = DynImage.getImage('images/toolzoomout_press.gif');
out_off = DynImage.getImage('images/toolzoomout_off.gif');
DynAPI.onLoad = function() {
// Create a layer for the buttons
var buttonLayer = new DynLayer(null,0,0,200,50,'#cccccc');
// Create a Zoom in button
var inButton = new Button(in_off);
inButton.moveTo(30,8);
inButton.setSize(30,30);
buttonLayer.addChild(inButton);
//create an event listener for the zoom in button
var inListener = new EventListener(inButton);
inListener.onclick = function(e) {
var o = e.getTarget();
var temp = document.forms[0].hdnIn.value;
temp = temp ^ 1;
if (temp==0) {
o.setImage(in_off);
}
else {
o.setImage(in_pressed);
}
document.forms[0].hdnIn.value = temp;
}
// Append the listener to the button
inButton.addEventListener(inListener);
// Create a zoom out button
var outButton = new Button(out_off);
outButton.moveTo(60,8);
outButton.setSize(30,30);
buttonLayer.addChild(outButton);
// Create an Event Listener for the zoom out button
var outListener = new EventListener(outButton);
outListener.onclick = function(e) {
var o = e.getTarget();
var temp = document.forms[0].hdnOut.value;
temp = temp ^ 1;
if (temp==0) {
o.setImage(out_off);
}
else {
o.setImage(out_pressed);
}
document.forms[0].hdnOut.value = temp;
}
// Append the zoom out listener to the button
outButton.addEventListener(outListener);
// Add the layer to the document
DynAPI.document.addChild(buttonLayer);
}
</script>
</HEAD>
<BODY BGCOLOR=#cccccc>
<FORM>
<INPUT ID=hdnIn NAME=hdnIN TYPE=hidden VALUE=0></INPUT>
<INPUT ID=hdnOut NAME=hdnOut TYPE=hidden VALUE=0></INPUT>
</FORM>
</BODY>
</HTML>
James F. Koennicke
Consultant
Vista Information Technologies, Inc.
2195 Fox Mill Road
Herndon, VA 20171
email: [EMAIL PROTECTED]
ph: (703) 561-4132
fax: (703) 561-4160
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help