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

Adobe Animate - AS3 Show button?

New Here ,
Nov 29, 2017 Nov 29, 2017

I'm probably going to drive myself insane with this one, but is it possible to make a button that only appears after you click three other buttons?

I'm trying to make an interactive fight sequence that "unlocks" the finale once you try the three fighting options. As usual, any help would be appreciated!

TOPICS
ActionScript
412
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

correct answers 1 Correct answer

Community Expert , Nov 29, 2017 Nov 29, 2017

yes.  here's one way:

var n:int=0;

var btnA:Array=[btn1,btn2,btn3];

for(var i:int=0;i<btnA.length;i++){

btnA.addEventListener(MouseEvent.CLICK,clickF);

}

function clickF(e:MouseEvent):void{

var i:int = btnA.indexOf(e.currentTarget);

n = Math.max(n,n ^ (1 << (i+1)));

if(n==Math.pow(2,btnA.length+1)-2){

// unlock whatever

}

}

here's another:

var n:int=0;

var btnA:Array=[btn1,btn2,btn3];

var clickedA:Array=[]

for(var i:int=0;i<btnA.length;i++){

btnA.addEventListener(MouseEvent.CLICK,clickF);

}

function clickF(e:MouseE

...
Translate
Community Expert ,
Nov 29, 2017 Nov 29, 2017

yes.  here's one way:

var n:int=0;

var btnA:Array=[btn1,btn2,btn3];

for(var i:int=0;i<btnA.length;i++){

btnA.addEventListener(MouseEvent.CLICK,clickF);

}

function clickF(e:MouseEvent):void{

var i:int = btnA.indexOf(e.currentTarget);

n = Math.max(n,n ^ (1 << (i+1)));

if(n==Math.pow(2,btnA.length+1)-2){

// unlock whatever

}

}

here's another:

var n:int=0;

var btnA:Array=[btn1,btn2,btn3];

var clickedA:Array=[]

for(var i:int=0;i<btnA.length;i++){

btnA.addEventListener(MouseEvent.CLICK,clickF);

}

function clickF(e:MouseEvent):void{

var i:int = btnA.indexOf(e.currentTarget);

if(clickedA.indexOf(i)==-1){

clickedA.push(i);

}

if(clickedA.length==btnA.length){

// unlock

}

}

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
New Here ,
Dec 01, 2017 Dec 01, 2017

Sorry it took a bit to respond to this, I've been a bit busy with other college projects.

I've put the code in, but I get this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@5b61b018431 to Array.

And when I go to click the buttons I want to trigger the button to show up, it also changes my volume (per the last request you helped me with). Of course, the button in question remains visible for the entire thing. Thank you for your response!

Edit: I managed to fix the volume changing. I don't really know how I did, but it doesn't affect that at least.

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 ,
Dec 01, 2017 Dec 01, 2017

if you have a movieclip named btnA, use something else for the array name.

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
New Here ,
Dec 01, 2017 Dec 01, 2017

Oh, oops. I assumed I needed to change btnA to the button I wanted to be shown. Changing it back to btnA fixed it! Thanks!

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 ,
Dec 01, 2017 Dec 01, 2017
LATEST

you're welcome.

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