Skip to main content
Leux
Participating Frequently
March 6, 2020
Answered

How to make it so that when I click 3 total movie clips, it disappears and takes me to a new frame?

  • March 6, 2020
  • 2 replies
  • 522 views

Hey everyone, I am creating a "iSpy" game, where you find objects and once you do, it will take you to a "winner screen"

 

How do I make it so that when after I click each of the objects (3 movieclips in total), they disappear right after? Also, how do I make it so that when I get a score of 3 (Each time I click an object, its +1) it takes me to a winner screen?

 

Any help would be appreciated as I'm not really sure how the delete function in actionscript works, but I do have an idea on how to set up the scoreBox which is listed below:

 

// I use my text tool add a text box and type Score: and then change it to dynamic text, then I add another text box right next to it, I make the instance name scoreBox and type nothing in it

var score = 0; // my variable for my starting score

scoreBox.text = score;

code here for deleting object 

score +=1;

scoreBox.text = score;

This topic has been closed for replies.
Correct answer S Hopkins

Hi, 

You can have all of your code in the first frame of the Actions layer. With a keyframe set with a label "Win", your code for ActionScript could read something like the following (your objects need to have instance names of myObject1, etc.):

stop();
var score = 0;

myObject1.addEventListener(MouseEvent.CLICK, addScore);
myObject2.addEventListener(MouseEvent.CLICK, addScore);
myObject3.addEventListener(MouseEvent.CLICK, addScore);

function addScore (event:MouseEvent):void {
score += 1;
scoreBox.text = String(score);
var target = event.target;
target.visible=false;
  if (score > 2) {
    gotoAndStop("Win");
  }
}

ps: take advantage of code snippets when you can.

2 replies

Legend
March 6, 2020

"Hey everyone, I am creating a "iSpy" game"

 

"I Spy", unless Apple is making surveillance equipment now.

Leux
LeuxAuthor
Participating Frequently
March 7, 2020

Do airpods count as surveillance equipment? They have a feature where you can turn "live listen" to "ON" and are able to leave your phone in a room with someone and hear what they're saying. Of course, its not really meant for that; its purpose is more of a hearing aid. 

S HopkinsCorrect answer
Inspiring
March 6, 2020

Hi, 

You can have all of your code in the first frame of the Actions layer. With a keyframe set with a label "Win", your code for ActionScript could read something like the following (your objects need to have instance names of myObject1, etc.):

stop();
var score = 0;

myObject1.addEventListener(MouseEvent.CLICK, addScore);
myObject2.addEventListener(MouseEvent.CLICK, addScore);
myObject3.addEventListener(MouseEvent.CLICK, addScore);

function addScore (event:MouseEvent):void {
score += 1;
scoreBox.text = String(score);
var target = event.target;
target.visible=false;
  if (score > 2) {
    gotoAndStop("Win");
  }
}

ps: take advantage of code snippets when you can.

Leux
LeuxAuthor
Participating Frequently
March 7, 2020

Thank you for your help!