I've got 2 radio buttons on a print screen and a button:
I want the "Connct to partnet" button to lead to different frames, depending on which radio button is clicked on the print screen.
So If "Remote control" is clicked, then the "connect to partner" gotoandStop at frame x
If "File transfer" is clicked, then the "connect to partner" will gotoandStop at frame x+1
I would really appreciate any help!
Thanks a lot in advance,
if you using Flex, like this
private function clickHandler(event:MouseEvent):void
{
var val:Object = radiogroup.selectedValue;
if(val == "foo")
{
// myMC.gotoAndStop(x);
}
else if(val == "bar")
{
// myMC.gotoAndStop(x + 1);
}
}
...
<fx:Declarations>
<s:RadioButtonGroup id="radiogroup"/>
</fx:Declarations>
<s:VGroup x="82" y="119">
<s:RadioButton label="Remote control" value="foo" groupName="radiogroup"/>
<s:RadioButton label="File transfer" value="bar" groupName="radiogroup"/>
</s:VGroup>
<s:Button x="82" y="179" label="Connect to Partner" click="clickHandler(event)"/>
If you have no experience coding with Actionscript at all, your best bet will be to search Google for tutorials about RadioButtons and Buttons. Try using search terms like "AS3 RadioButton tutorial" and similarly for a Button. You might get lucky and find one that does pretty much what you are trying to do. Here's a link to one of the first results found using that search... it appears to have similarities to what you are doing if you look thru all three parts of it.
http://kirill-poletaev.blogspot.com/2010/09/using-radiobutton-componen t.html
Thanks a lot! I now know how to create and link radio buttons!
The thing is that I'm not using actual radio buttons on my print screen (sorry my post was so confusing) but simple buttons on a Print screen that shows 2 radio buttons. I've just added 2 simple buttons on the prrint screen, on top of Remote Control and File transfer. I have a visible = true and false coding when clicking on the buttons, so it looks as if a radio button is selected when I click on the simple button.
So is it possible to do the same thing with normal buttons? Link simple b1 (Remote Control) + b2 (File transfer) to the main B3 (Connect to partner)? So that:
Remote Control button clicked + Connect to Partner button cliked = frame x
File Transfer button + Connect to Partner = frame +1
Thanks a looot!
one of the ways you can do this is by creating an extra variable such as:
var whichButton:*
//---
and then when you set the visible = true by clicking one of the "simple buttons", set a value for whichButton:
whichButton = "remoteControl"
or
whichButton = "fileTransfer"
//---
and then when you click "connect to partner", you can use the if/else as shown above:
if(whichButton == "remoteControl")
{
// ctp.gotoAndStop(framex);
}
else if(whichButton == "fileTransfer")
{
// ctp.gotoAndStop(framex + 1);
}
Thank you!
I am gentting error "Access of undefined property or" when I test the movie with this script:
var whichButton:*
filetransfer_btn.addEventListener(MouseEvent.CLICK,reveal);
function reveal(event:MouseEvent):void{
radio.visible = true;
}
remote_btn.addEventListener(MouseEvent.CLICK, remote);
function remote(event:MouseEvent):void{
radio.visible = false;
}
whichButton = "filetransfer_btn"; or
whichButton = "remote_btn"
//---
if(whichButton == "filetransfer_btn")
{
// ctp.gotoAndStop(1);
}
else if(whichButton == "remote_btn")
{
// ctp.gotoAndStop(158);
}
No, the coding does not look okay... remove the "or" if you can't find it, use the search feature (the magnifying glass in the top toolbar)
Also, I won't say that the code is okay or will work at all for what you are after. That would be up to whoever gave it to you to work out with you. I generally avoid intruding on other people's efforts to help. So when someone else decides they want to do so, it's up to them to follow thru and support what they offer. Try emailing whoever gave you the code to get their help if they are not following up on it.
...please understand that i dont know how you toggle the radio buttons... i only saw you say: "I have a visible = true and false coding when clicking on the buttons, so it looks as if a radio button is selected when I click on the simple button."
...also, since you didnt show the function for clicking the connect button, i made one up so you can see the logic that i intended
//---
Remote Control button clicked + Connect to Partner button cliked = frame x
File Transfer button + Connect to Partner = frame +1
//---
//sets a default value, in case neither radio button gets clicked
var whichButton:* = "filetransfer_btn";
filetransfer_btn.addEventListener(MouseEvent.CLICK,reveal);
function reveal(event:MouseEvent):void{
radio1.visible = true;
radio2.visible = false;
whichButton = "filetransfer_btn";
}
remote_btn.addEventListener(MouseEvent.CLICK, remote);
function remote(event:MouseEvent):void{
radio2.visible = true;
radio1.visible = false;
whichButton = "remote_btn"
}
connectToPartner.addEventListener(MouseEvent.CLICK, connect);
function connect(event:MouseEvent):void{
if(whichButton == "filetransfer_btn")
{
gotoAndStop(framex);
}
else if(whichButton == "remote_btn")
{
gotoAndStop(framex +1);
}
}
North America
Europe, Middle East and Africa
Asia Pacific