Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become an Expert!

Join 244,296 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 868 people online right now. Registration is fast and FREE... Join Now!




Character Generator problem

 
Reply to this topicStart new topic

Character Generator problem

pancreasboy
30 Nov, 2008 - 02:32 PM
Post #1

New D.I.C Head
*

Joined: 30 Nov, 2008
Posts: 4

Hi there I have a question for my Character Generator I'm making for a Tabletop game I'm developing, and I've uploaded the problem file here http://www.twistedpancreas.com/test/strongProblem.fla (http://www.twistedpancreas.com/test/strongProblem.swf).

You get to type in your Str value and then later on could choose a Trait like Strong (ie type in a value next to Strong then click Strong), problem is I have the Str input value in a onEnterFrame (so that you get instant feedback on how much the Str value costs), and so when the Strong trait value gets added to the Str value it appears for a millisecond then reverts to what was originally typed.

How do I get the Strong value to remain added to the Str value?

Because i would have thought the Strong button code inside "traits_mc" would have this:

gStrCost = Number(gStrCost) + (Number(myStrongTxt.text));

but that doesnt seem to work sad.gif

Any help would be appreciated.

Thanks in advance.

User is offlineProfile CardPM
+Quote Post


CyanBlue
RE: Character Generator Problem
2 Dec, 2008 - 12:18 PM
Post #2

D.I.C Head
Group Icon

Joined: 1 Sep, 2006
Posts: 155



Thanked: 4 times
My Contributions
What do you get if you add this line right before your code???
as
trace("gStrCost = " + gStrCost + " : " + "myStrongTxt.text = " + myStrongTxt.text);

Also, try using parseInt() function instead of Number() function and see if that makes any difference...
User is offlineProfile CardPM
+Quote Post

pancreasboy
RE: Character Generator Problem
2 Dec, 2008 - 02:04 PM
Post #3

New D.I.C Head
*

Joined: 30 Nov, 2008
Posts: 4

Thanks CyanBlue over all the forums you're the only one to have replied to me yet, so so far you're my lifeline smile.gif

Thanks.

Ok I put you're trace in "traits_mc" at frame 21 AS and got

CODE
gStrCost = 0 : myStrongTxt.text = 0


which seems fine and i tried you're parseInt but that didn't seem to work, see my updated file here: http://www.twistedpancreas.com/test/strongProblem1.fla


User is offlineProfile CardPM
+Quote Post

pancreasboy
RE: Character Generator Problem
4 Dec, 2008 - 03:33 AM
Post #4

New D.I.C Head
*

Joined: 30 Nov, 2008
Posts: 4

well it looks like

strongStr = (Number(_root.myStrTxt.text)) + (Number(myStrongTxt.text))

_root.myStrTxt.text = strongStr;

does the trick to adjust the Str Lvl stat, see http://www.twistedpancreas.com/test/costProblem.swf

but it shouldn't adjust the Str Lvl cost beside it, anybody got any ideas on how I could avoid that? Updated file is here http://www.twistedpancreas.com/test/costProblem.fla

This post has been edited by pancreasboy: 4 Dec, 2008 - 02:01 PM
User is offlineProfile CardPM
+Quote Post

CyanBlue
RE: Character Generator Problem
4 Dec, 2008 - 07:48 PM
Post #5

D.I.C Head
Group Icon

Joined: 1 Sep, 2006
Posts: 155



Thanked: 4 times
My Contributions
I really can't take a look at your FLA file... Can you post the appropriate code???
User is offlineProfile CardPM
+Quote Post

pancreasboy
RE: Character Generator Problem
4 Dec, 2008 - 08:09 PM
Post #6

New D.I.C Head
*

Joined: 30 Nov, 2008
Posts: 4

No problem CyanBlue,

I've got the code adding to the Str Lvl now and not adjusting the cost, the problem is when the user removes the Strong trait from the datagrid how will I get Flash to minus it off the Str Lvl without adjusting the cost?

On the main timeline I have:

CODE


_global.gFinalCost = 0;
_global.gStrCost = 0;
_global.gStrongStr = 0;

myStrTxt.restrict = "0-7";

traits = new Array();
traits = [{TRAITS:"",LVL:"",$:""}];
traitsGrid.dataProvider = item;
traitsGrid.setSize(200,70);
traitsGrid.editable = false;
traitsGrid.dataProvider.removeItemAt(0);

remove_btn.onRelease = function ()
{
    if(traitsGrid.selectedIndex <> undefined) {
        //trace(weapGrid.dataProvider[weapGrid.selectedIndex]["Cost"]);
        _global.gFinalCost -= Number(traitsGrid.dataProvider[traitsGrid.selectedIndex]["$"]);
        traitsGrid.dataProvider.removeItemAt(traitsGrid.selectedIndex);
        _global.gStrong = _global.gStrong - _global.gStrong;
        
    }
    
}

var gSCArray = new Array("0","1","5","10","15","20","30","50");

onEnterFrame = function(){
    
    _global.gStrCost = gSCArray[Number((myStrTxt.text) - Number(_global.gStrongStr))]
                          
myStrCostTxt.text = gStrCost

finalCost.text = Number(gStrCost) + Number(gFinalCost);

}



And in the traits_mc I have :

CODE


strong_btn.onRelease = function () {
    
    strongStr = (Number(_root.myStrTxt.text)) + (Number(myStrongTxt.text))
    
    _root.myStrTxt.text = strongStr;
    
    _global.gStrongStr = Number(myStrongTxt.text)
    
    _root.traitsGrid.addItem({TRAIT:"Strong",LVL:Number(myStrongTxt.text),$:_root.gSCArray[Number(myStrongTxt.text)]});
    _global.gFinalCost += Number(_root.gSCArray[Number(myStrongTxt.text)]);
    
    gotoAndStop(1);
    
}


This post has been edited by pancreasboy: 4 Dec, 2008 - 08:10 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 04:38PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month