Skip to main content
Participant
February 26, 2014
Question

How to solve this problem with these variables in timeline?

  • February 26, 2014
  • 1 reply
  • 282 views

I have been making a random dice roll game in Flash CS5.

When a user rolls the dice, a random face is thrown and that value is added to score. The concept of the game is, the player must get 20 points in 10 tries. I didn't use external classes, instead I used the code in timeline.

The problem I have is the score is not getiing added up and the triesLeft variable is not decreasing by one.

I used

triesLeft--;//initial value is 10

and for the face value frames,

i used

score+=1;//initial value is 0

score+=2;

and so on...

i think the function runs only once.

this is the swf file of this game.

http://www.fastswf.com/swfs/3dLgfZI

if anybody need source files to see the problem more clearly i will upload it.

This topic has been closed for replies.

1 reply

Inspiring
February 26, 2014

i think the function runs only once.

correct.

You have to put your functionality inside a function

for example:

function rollDice(e:MouseEvent):void{

triesLeft--;

//plus anything you might need done

}

then make a movieclip/button instance on stage and add the eventlistener above to it

myButton.addEventListener(MouseEvent.CLICK, rollDice);