3 Replies - 1679 Views - Last Post: 15 January 2012 - 12:18 PM

#1 jk145  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 09-January 12

question about using radio buttons in actionscript 3.0

Posted 09 January 2012 - 03:15 PM

Is it possible, (and if so, how), to move to a different frame when a radio button is selected? I have tried

button1.onPress=gotoAndStop(1);
{

}



Is This A Good Question/Topic? 0
  • +

Replies To: question about using radio buttons in actionscript 3.0

#2 jk145  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 09-January 12

Re: question about using radio buttons in actionscript 3.0

Posted 13 January 2012 - 04:28 PM

After much further searching, I found the code myself.

radio1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
	gotoAndStop(2);
}


Was This Post Helpful? 0
  • +
  • -

#3 jk145  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 09-January 12

Re: question about using radio buttons in actionscript 3.0

Posted 14 January 2012 - 09:27 AM

View Postjk145, on 13 January 2012 - 04:28 PM, said:

After much further searching, I found the code myself.

radio1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
	gotoAndStop(2);
}



This works for whenever someone clicks the radio button, but it will do the action whether you are selecting or deselecting it. I have tried to find how to do the action only when you are selecting it, but I haven't found anything that will work yet. What am I missing.
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,144
  • Joined: 07-September 06

Re: question about using radio buttons in actionscript 3.0

Posted 15 January 2012 - 12:18 PM

I am not sure your question makes a ton of sense with radio buttons. If you click on it and it is enabled it will always be selecting the radio, never unselecting it. A checkbox would make more sense here...

However, there is the selected attribute which is either set to true or false on the RadioButton and CheckBox components; you can use that to see if something was selected when clicked or not.

Example:
import flash.events.MouseEvent;
import flash.display.MovieClip;

r1.addEventListener(MouseEvent.CLICK, onclick);

function onclick(evt:MouseEvent):void{
	var target:RadioButton = evt.target as RadioButton;
	trace(target.selected);
}


Hope that helps.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1