Adding Filters to Button States
Monday, May 23rd, 2011This simple tutorial demonstrates how to add a separate Over state to a button and then apply a green glow filter.
The following screencast shows how to make this button. (more…)
This simple tutorial demonstrates how to add a separate Over state to a button and then apply a green glow filter.
The following screencast shows how to make this button. (more…)
Recently I found myself modifying the supplied component buttons to produce sound on/off and play/pause buttons. Although this is easy enough to do, I thought it would save everyone some time if I included these as standard component buttons.
As can be seen in the above example, each type of button is duplicated to allow a default state of on or off. In the example, all of the buttons call the same event handling function (Events) which displays the calling button name and the current button state within the scrolling text box. (more…)
The radio button component is one of the more popular components supplied with SWiSHÂ Max2 and SWiSHÂ miniMax2. A radio button is useful when a user needs to select only one choice from a number of alternatives. This article demonstrates how to use the radio button component.
Click to Download – radiobutton.swi
The radio button component can be found in the Buttons > Radiobutton component category. To use this component, drag the required number of the Radio button components onto the stage. In the Parameters panel for the first radio button, change the Label to “Choice 1″, Group Name to “myChoice” and the Value to 10. If you wish you can also change the color of the dot that shows when the button is selected.
The Component Buttons supplied with SWiSH Max2 (and miniMax2) provide an easy way to add buttons to your movie. Quite often these buttons are used in a toggle mode – for example to play or pause a movie. In this case it is useful to change the text (or icon) displayed for each button state. Read on to find out how.
To toggle the Button text displayed
The following steps apply to the Button_ or any of the fancy button components:
onSelfEvent (load) {
ProgressCircle.stop(); // initially stop the target movie
}
function Events(n,v) {
// If a component has "Events" defined as its event function,
// then this function will be called when the component changes state.
// n is the name of the component, v is the new value.
// if the component is a toggle button, v will be true or false
// representing the state of the button.
if ("Button_Play" == n) {
if (v) {
// button says play
Button_Play.label.text = "Pause"; // show button now as pause button
ProgressCircle.play(); // play the target movie
} else {
// button says stop / pause
Button_Play.label.text = "Play";
ProgressCircle.stop(); // stop the target movie
}
}
}
To toggle the Button icon displayed
onSelfEvent (load) {
_visible = false;
}
onSelfEvent (load) {
ProgressCircle.stop(); // initially stop the target movie
}
function Events(n,v) {
// If a component has "Events" defined as its event function,
// then this function will be called when the component changes state.
// n is the name of the component, v is the new value.
// if the component is a toggle button, v will be true or false
// representing the state of the button.
if ("Button_Play" == n) {
if (v) {
// button says play
Button_Play.icon_holder.pause._visible = true;// show button now as pause button
Button_Play.icon_holder.play._visible = false;
ProgressCircle.play(); // play the target movie
} else {
// button says stop / pause
Button_Play.icon_holder.pause._visible = false;// show button now as play button.
Button_Play.icon_holder.play._visible = true;
ProgressCircle.stop(); // stop the target movie
}
}
}
Done! You can download Sample SWIs here.
Enjoy!