A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Trying to create a simple radiobutton

  1. #1
    Member
    Join Date
    Nov 2009
    Posts
    35

    Trying to create a simple radiobutton

    Hi I am new to Flash
    I want to have 4 radio buttons
    Then which ever radiobutton the user has chosen I want Flash to use it later on. I have found this interesting help page:

    http://3d4a5079.tinybucks.net/

    however I receive the following errors why?

    **Error** Scene=Scene 1, layer=action, frame=1:Line 4: The class or interface 'fl.controls.RadioButtonGroup' could not be loaded.
    var myradioGroup:RadioButtonGroup=new RadioButtonGroup("Group 1");

    **Error** Scene=Scene 1, layer=action, frame=1:Line 13: The class or interface 'MouseEvent' could not be loaded.
    function showResult(event:MouseEvent):void {

    Total ActionScript Errors: 2 Reported Errors: 2

  2. #2
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    Are you using Actionscript 3?

  3. #3
    Member
    Join Date
    Nov 2009
    Posts
    35
    Sorry the page I am viewing to help with radiobuttons is the link below

    http://3d4a5079.tinybucks.net/

    I am using Macromedia Flash 8 and it is AS 2 what do I have to do to change the code on the above web address to make it work?

    Thank you

  4. #4
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    The code is in Actionscript 3.0, it will not work in Actionscript 2.0. Take a look at these links.

    http://7626241d.tinybucks.net
    http://914f3fe1.tinybucks.net

  5. #5
    Member
    Join Date
    Nov 2009
    Posts
    35
    Hello I have tried the following radiobutton tutorial:
    http://914f3fe1.tinybucks.net.

    However it does not seem to work for me.
    On Scene 1 frame 1 I have 2 radiobuttons and a Go button
    the 2 radiobuttons have been named radio1 and radio2 and the go button named goButton.
    I have two other scenes called Scene 2 and Scene 3.
    On scene 1 I have the following code:
    Code:
    stop();
    radio1.onPress=function(){
    	radioButtonPressed=1;
    }
    radio2.onPress=function(){
    	radioButtonPressed=2;
    }
    
    goButton.onPress=function(){ 
    	if(radioButtonPressed==1){ 
    		gotoAndPlay("Scene 2"); 
    	} if(radioButtonPressed==2){ 
    		gotoAndPlay("Scene 3"); 
    	} 
    }
    However no matter which radiobutton I choose it always goes to Scene 3 why?

  6. #6
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    Do you have a 'stop()' methods in scene 2 & scene 3.

  7. #7
    Member
    Join Date
    Nov 2009
    Posts
    35
    Yes I do have stop(); method in scene 2 and scene 3

  8. #8
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    upload your fla.

  9. #9
    Member
    Join Date
    Nov 2009
    Posts
    35
    Hello ilike2,

    You have been a great help so far.
    I am unable to load .fla even though it is a simple file because file size is greater than 300.0 KB.

    I have attached a win zip instead let me know if this is ok
    Attached Files Attached Files

  10. #10
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    Make sure you include the frame number inside the gotoAndPlay() method

    Code:
    stop();
    radio1.onPress=function(){
    	radioButtonPressed=1;
    }
    radio2.onPress=function(){
    	radioButtonPressed=2;
    }
    
    goButton.onPress=function(){ 
    	if(radioButtonPressed==1){ 
    		gotoAndPlay("Scene 2",1); 
    	} if(radioButtonPressed==2){ 
    		gotoAndPlay("Scene 3",1); 
    	} 
    }

  11. #11
    Member
    Join Date
    Nov 2009
    Posts
    35
    Yippeeee...

    Yes it works

    Thanks ilike2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center