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

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

Community Beginner ,
Oct 22, 2024 Oct 22, 2024

Copy link to clipboard

Copied

akbar_mahardhika_0-1729611353701.png

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

 

Views

247

Translate

Translate

Report

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

Copy link to clipboard

Copied

yes.

 

create your graphics and use code to control their behavior.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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);
}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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);
}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi.

 

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

Regards,

JC

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

It's Actionscript 3

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

what problem are you having?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

No, I'm not ;')

Votes

Translate

Translate

Report

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