Hi all,

I'm trying to create a simple script. You press a button and you have 50% chances of doubling your current score. If you lose, you lose 100 gold/points. To achieve this I used the Math.random() function to give me two options: 1 (win) and 2 (lose).

I have a dynamic text called "total" where it displays your current score.

The problem is, I don't know why the score doesn't update when you press the button. Here's the code:

PHP Code:
import flash.events.MouseEvent;
import flash.events.Event;

stop();


var 
coins:int 100000000;
var 
coinsString:String String(coins);
    
    
bet100.addEventListener(MouseEvent.CLICKgamble);

function 
gamble(event:MouseEvent):void
{
    var 
lucky:Number Math.floor(Math.random()*2)+1;
    
    if(
lucky == 1)
    {
        
//trace("YOU WIN!");
        
status.text String("You WON +200 GOLD!");
        
coins += 200;
    }
    else
    {
        
status.text String("You lost 100 gold...");
        
coins -= 100;
    }
}

total.text coinsString