Saturday, December 6, 2008

User option button

Hi,
In this i like to explain how to create User option button.

create a movie clip with two frames and make the first frame as off and second as on.
Place the art work like on a option button in first frame as off and second one as on and place a stop(); command in the first frame action script window so it will resemble as the below one...



copy and past the same movie clip option in the main time line and name it as op1 and op2.
which look like the image specified below.


//code is as followes
op1.gotoAndStop("on"); //set The option 1 as default on
op2.gotoAndStop("off"); //set The option 2 as default off
_root.selected_option=1; //storing the selected value for future reference

//function for option 1 button when clicked
op1.onRelease = function()
{
if(_root.selected_option<>1) //check weather the option 1 is not selected
{//if not selected
op1.gotoAndStop("on"); //make the option1 movie clip as on
op2.gotoAndStop("off"); //make the option2 movie clip as off
_root.selected_option=1; //set the value as 1
}
}

//function for option 2 button when clicked
op2.onRelease = function()
{
if(_root.selected_option<>2) //check weather the option 2 is not selected
{//if not selected
op1.gotoAndStop("off");//make the option1 movie clip as off
op2.gotoAndStop("on");//make the option2 movie clip as on
_root.selected_option=2; //set the value as 2
}
}

No comments: