Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Oct 22, 2024 Oct 22, 2024

akbar_mahardhika_0-1729611353701.png

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

 

376
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2024 Oct 22, 2024

yes.

 

create your graphics and use code to control their behavior.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2024 Oct 23, 2024

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2024 Oct 23, 2024
LATEST
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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2024 Oct 22, 2024

Hi.

 

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

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2024 Oct 23, 2024

It's Actionscript 3

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2024 Oct 23, 2024

what problem are you having?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2024 Oct 23, 2024

Thanks.

 

Are you familiar with using classes and other Object Oriented Programming concepts?

 

It's not mandatory to use OOP for this, but I think it's a very good candidate for radio buttons.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2024 Oct 23, 2024

No, I'm not ;')

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines