Question:

Flash ActionScript help?

by  |  earlier

0 LIKES UnLike

Can anyone tell me how to make it so when a certain movieclip is clicked the score will go up by a certain ammount. And then score is displayed on the screen, the score is in a label... or just a number in the top left corner of the screen.

 Tags:

   Report

1 ANSWERS


  1. Copy and paste this code to the first frame of ur flash document CS3 | As3

    var score:int = 0;

    var shapeOne = new MovieClip();

    addChild (shapeOne);

    shapeOne .x = 100;

    shapeOne .y = 100;

    shapeOne .graphics.beginFill(0xE87900, 1);

    shapeOne .graphics. drawRoundRect (0, 0, 50, 50, 30, 30);

    shapeOne. graphics.endFill();

    shapeOne. buttonMode = true;

    var shapeTwo = new MovieClip();

    addChild (shapeTwo);

    shapeTwo .x = 200;

    shapeTwo .y = 100;

    shapeTwo .graphics.beginFill(0x00CCFF, 1);

    shapeTwo .graphics.drawRoundRect(0, 0, 50, 50, 30, 30);

    shapeTwo .graphics.endFill();

    shapeTwo .buttonMode = true;

    var ScoreBoard = new TextField();

    addChild (ScoreBoard);

    ScoreBoard .x=150;

    ScoreBoard .y=50;

    ScoreBoard .border=true;

    ScoreBoard .height=20;

    shapeOne. addEventListener (MouseEvent.CLICK,increaseHandler);

    shapeTwo. addEventListener (MouseEvent.CLICK ,decreaseHandler);

    function increaseHandler (e:MouseEvent) : void {

    score ++;

    ScoreBoard .text=score;

    }

    function decreaseHandler (e:MouseEvent) : void {

    score --;

    ScoreBoard.text=score;

    }

    Anil

    anilkumarnd@gmail.com

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.