Button element (used with Interface module)
Description:
This element is used to create buttons within an interface. Buttons can be either image based, or text buttons with coloured backgrounds. Buttons can be grouped together to create the equivalent of radio buttons in a form. So when one button is pressed in, all the others in the group will not be pressed in. Otherwise, they act as normal form buttons, and will pop out after being pressed.
To use:
The code for this element is included in the interface module, linked as follows:
<script language="Javascript" src="gamelib_interface.js"></script>
You then instantiate a button object by using one of the following methods depending if it's a text type button, or an image type button (the parameters are commented in the examples, you can obviously have all the parameters on the same line, but I've spaced them out to help make things more readable.):
// Example of a text button
myButton=new In_Button(
155, // x position
128, // y position
80, // width
20, // height
"text", // type of button
"myButton6.setLegend('Fred')",// statement to be executed when button clicked
"Button 4", // button text
"#aaaa88", // button mouse out color
"#ddddbb", // button mouse over color
"#ffff00", // button mouse click color
"#000000", // button border color
"#000000", // button font color
2 // font size for button text
);
// Example of an image button
myButton=new In_Button(
110, // x position
125, // y position
60, // width
20, // height
"image", // type of button
"alert('Button 1 pressed!')", // statement to be executed when button clicked
"../images/button1.gif", // button initial image
"../images/button1.gif", // button mouse out image (usually same as above)
"../images/button1hi.gif", // button mouse over image
"../images/button1click.gif" // button mouse click image
);
List of methods for Buttons
click
clearRadio
makeRadio
setAction
setColors
setImages
setLegend
Descriptions of methods for Buttons