Here is the link to a game i'm working on:
If you make it to day 20 adventurers come to you, and ask for help funding an adventure. They promise you can keep what they find. to do this, i made a fund variable, and "funds" is increased by 100 every time a button is pressed. after you hit accept, it deducts "funds" from "gold" and sets funds back to 0 so that the next time around it starts over. It works fine the first time through, but i can't seem to get it to work for any time after that. Here is the bit of code for this:
if(aDays == 20)
{
trace(funds);
var AdventureTween:Tween;
var Adventuer2Tween:Tween;
AdventureTween = new Tween(AdventureWindow,"x",Strong.easeOut,-296,375,24);
//IF YOU DON'T WANT TO FUND MONEY//
AdventureWindow.no.addEventListener(MouseEvent.CLICK, noAdven)
function noAdven(event:MouseEvent)
{
AdventureTween = new Tween(AdventureWindow,"x",Strong.easeOut,375,-296,24);
aDays = aDays - aDays;
}
//IF YOU DO WANT TO FUND MONEY//
AdventureWindow.yes.addEventListener(MouseEvent.CLICK, startAdv)
function startAdv(event:MouseEvent)
{
Adventure2Window.fundText.text = String(funds);
AdventureTween = new Tween(AdventureWindow,"x",Strong.easeOut,375,-296,24);
Adventuer2Tween = new Tween(Adventure2Window,"x",Strong.easeOut,-296,375,24);
Adventure2Window.upFund.addEventListener(MouseEvent.CLICK, incFund)
function incFund(event:MouseEvent)
{
if(gold >= funds)
{
funds = funds + 100;
trace("funds:",funds);
Adventure2Window.fundText.text = String(funds);
}
if(funds >= gold)
{
funds = gold;
trace("funds:",funds);
Adventure2Window.fundText.text = String(funds);
}
}
Adventure2Window.downFund.addEventListener(MouseEvent.CLICK, decFund)
function decFund(event:MouseEvent)
{
if(funds <= 100)
{
funds = 0;
trace("funds:",funds);
Adventure2Window.fundText.text = String(funds);
}
if(funds > 0)
{
trace("funds:",funds);
funds = funds - 100;
Adventure2Window.fundText.text = String(funds);
}
}
Adventure2Window.acceptButt.addEventListener(MouseEvent.CLICK, Adventure)
function Adventure(event:MouseEvent)
{
//THIS IS WHERE FUNDS UPDATE IS IN THE ADVENTURE2WINDOW//
//INCLUDE THE DISCOVERY HERE BASED ON 15% 30% 45%//
gold = gold - funds;
adventureOn = true;
goldText.text = String(gold);
aDays = aDays - aDays;
AdventureTween = new Tween(Adventure2Window,"x",Strong.easeOut,375,-296,24);
}
}
}
//WHEN THE ADVENTURES RETURN//
if(aDays == 10)
{
trace(funds);
trace("Adays = 10")
if(funds >= 500 && funds <= 10000)//FOR 500 TO 10,000 - 15% CHANCE TO GET//
{
funds = funds - funds;
trace(funds);
trace(chance);
AdventureReturn = new Tween(AdventureReturnW,"x",Strong.easeOut,-296,375,24);
chance = Math.round(Math.random() * 100)
if(chance >= 0 && chance <= 45)//-----45% CHANCE TO GET THIS ------//
{
cloth = cloth + 150;
itemsMenu.clothAmt.text = String(cloth);
trace("The adventurer's have retured!")
}
}
if(funds >= 10000 && funds <= 50000)//FOR 500 TO 10,000 - 15% CHANCE TO GET//
{
funds = 0;
trace(chance);
AdventureReturn = new Tween(AdventureReturnW,"x",Strong.easeOut,-296,375,24);
chance = Math.round(Math.random() * 100)
if(chance >= 0 && chance <= 55)//-----55% CHANCE TO GET THIS ------//
{
cloth = cloth + 150;
itemsMenu.clothAmt.text = String(cloth);
trace("The adventurer's have retured!")
}
}
if(funds >= 50000 && funds <= 100000)//FOR 500 TO 10,000 - 15% CHANCE TO GET//
{
funds = 0;
trace(chance);
AdventureReturn = new Tween(AdventureReturnW,"x",Strong.easeOut,-296,375,24);
chance = Math.round(Math.random() * 100)
if(chance >= 0 && chance <= 75)//-----75% CHANCE TO GET THIS ------//
{
cloth = cloth + 150;
itemsMenu.clothAmt.text = String(cloth);
trace("The adventurer's have retured!")
}
}
var AdventureReturn:Tween;
if(adventureOn == true)
{
adventureOn = false;
AdventureReturn = new Tween(AdventureReturnW,"x",Strong.easeOut,-296,375,24);
funds = funds - funds;
}
}
AdventureReturnW.addEventListener(MouseEvent.CLICK, adventureReturnReturn)
function adventureReturnReturn(event:MouseEvent)
{
AdventureReturn = new Tween(AdventureReturnW,"x",Strong.easeOut,375,-296,24);
}
it may seem like a lot, but i would really appreciate any help.