Skip to main content
Participant
May 6, 2013
Answered

Hi guys im completely new to this so go easy

  • May 6, 2013
  • 1 reply
  • 597 views

Basically i'm trying to get this function to add one to a variable and then when the variable hits a certian number I want it to go to a different page. Heres the code ive come up with

var Hit:Number=0;

Cymbol2.addEventListener(MouseEvent.CLICK, DrumBeat);

Kick2.addEventListener(MouseEvent.CLICK, DrumBeat);

function Drumbeat (event:MouseEvent) :void {Hit=+1}

function checkPage(e:Event):void {

    if (Hit==3) {

        gotoAndPlay("Bedroom1");

    }

}

Any help would be greatly appreciated

This topic has been closed for replies.
Correct answer kglad

use:

var Hit:Number=0;

Cymbol2.addEventListener(MouseEvent.CLICK, DrumBeat);

Kick2.addEventListener(MouseEvent.CLICK, DrumBeat);

function Drumbeat (e:MouseEvent) :void {

Hit+=1;

checkPage(e);

}

function checkPage(e:Event):void {

    if (Hit==3) {

        gotoAndPlay("Bedroom1");

    }

}

1 reply

kglad
Community Expert
Community Expert
May 6, 2013

use:

var Hit:Number=0;

Cymbol2.addEventListener(MouseEvent.CLICK, DrumBeat);

Kick2.addEventListener(MouseEvent.CLICK, DrumBeat);

function Drumbeat (event:MouseEvent) :void {

Hit+=1;

checkPage(e);

}

function checkPage(e:Event):void {

    if (Hit==3) {

        gotoAndPlay("Bedroom1");

    }

}

Participant
May 6, 2013

Thank you so much for the reply, tried this code out and I get an error code which says "access of undefined property e" what would I need to change to correct this?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 6, 2013

use:

var Hit:Number=0;

Cymbol2.addEventListener(MouseEvent.CLICK, DrumBeat);

Kick2.addEventListener(MouseEvent.CLICK, DrumBeat);

function Drumbeat (e:MouseEvent) :void {

Hit+=1;

checkPage(e);

}

function checkPage(e:Event):void {

    if (Hit==3) {

        gotoAndPlay("Bedroom1");

    }

}