Copy link to clipboard
Copied
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!
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
...Copy link to clipboard
Copied
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
}
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
if you have a movieclip named btnA, use something else for the array name.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now