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

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

Community Beginner ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

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;

TOPICS
ActionScript

Views

273

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

correct answers 1 Correct answer

Enthusiast , Mar 06, 2020 Mar 06, 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.tex

...

Votes

Translate

Translate
Enthusiast ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

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.

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 ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

Thank you for your help!

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
LEGEND ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

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

 

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

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 ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

LATEST

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. 

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