Skip to main content
akbar_mahardhika
Participant
Oct 22, 2024 3:36 PM UTC
Question

Can We make Radio Button from scratch in animate by using Movie Clip?

What the best way to make this working like a radio button?

 

    This topic is closed to new replies. Start a new post to keep the conversation going.

    8 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    Oct 22, 2024 4:08 PM UTC

    Hi.

     

    Adding to k's answer, is it AS3 or HTML5 Canvas?

    Regards,

    JC

    Translate
    akbar_mahardhika
    Participant
    Oct 23, 2024 3:07 PM UTC

    It's Actionscript 3

    Translate
    kglad
    Community Expert
    Community Expert
    Oct 23, 2024 3:11 PM UTC

    what problem are you having?

    Translate
    kglad
    Community Expert
    Community Expert
    Oct 22, 2024 3:57 PM UTC

    yes.

     

    create your graphics and use code to control their behavior.

    Translate
    akbar_mahardhika
    Participant
    Oct 23, 2024 3:15 PM UTC

    I'm using this code but it doesn't work when question (in this case movie clip) is more than one. How can we fix this and not have any error?

    import flash.events.MouseEvent;

    stop();

     

    var Pilihan1:MovieClip = MovieClip(this.getChildByName("Pilihan1"));

     

    Pilihan1.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    Pilihan1.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    Pilihan1.addEventListener(MouseEvent.CLICK, mouseClickHandler);

     

    function mouseOverHandler(e:MouseEvent){
    if(e.target.currentFrame<3){
    e.target.gotoAndStop(2);
    }
    }

    function mouseOutHandler(e:MouseEvent){
    if(e.target.currentFrame<3){
    e.target.gotoAndStop(1);
    }
    }

    function mouseClickHandler(e:MouseEvent){
    e.target.gotoAndStop(3);
    Pilihan1.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    Pilihan1.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    Pilihan1.removeEventListener(MouseEvent.CLICK, mouseClickHandler);
    }

    Translate
    kglad
    Community Expert
    Community Expert
    Oct 23, 2024 3:46 PM UTC
    import flash.events.MouseEvent;
     
    stop();
     
     
     
    //var Pilihan1:MovieClip = MovieClip(this.getChildByName("Pilihan1"));  <-superfluous
    var pilihanA:Array =[Pilihan1,Pilihan2,Pilihan3];  // <- list all the buttons in the family
     
     
    for(var i:int=0;i<3;i++){
    pilihanA[i].addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    pilihanA[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    pilihanA[i].addEventListener(MouseEvent.CLICK, mouseClickHandler);
    }
     
     
    function mouseOverHandler(e:MouseEvent){
    if(e.target.currentFrame<3){
    e.target.gotoAndStop(2);
    }
    }
     
    function mouseOutHandler(e:MouseEvent){
    if(e.target.currentFrame<3){
    e.target.gotoAndStop(1);
    }
    }
     
    function mouseClickHandler(e:MouseEvent){
    for(var i:int=0;i<3;i++){
    pilihanA[i].gotoAndStop(1);
    }
    e.target.gotoAndStop(3);
    Pilihan1.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    Pilihan1.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    Pilihan1.removeEventListener(MouseEvent.CLICK, mouseClickHandler);
    }
    Translate