A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: grrrr.....please restore my faith in flash 5...

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    10
    i am messing with ideas for a dice game and have made a little prototype. i have it set up simply with a script to roll 2 dice and calculate the total!

    members.aol.com/gilbertgbert/dietest2.fla

    the problem is...it comes up with the correct total for 2 dice MOST of the time but not always!!!

    i could understand if it never worked but it seems to be randomly breaking and it's driving me nuts....

    if anyone could please check the .fla and explain why it may work MOST of the time i would be VERY grateful. (btw i know that the way i've done this is not the best way but i'm most interested in why it doesn't work rather than a better method of doing this- although that would be nice too!!).

    just click roll then see the total and reset, before long it will come up with an incorrect total!!

  2. #2
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514
    I'm intrigued by this problem and would like to help. I downloaded your file and haven't really gotten into it yet, but I noticed a small issue:
    I would change the variable name of your scrore text field. Instead of _root.compTotal, it should just be compTotal.
    The, the movie clip that contains it should have an instance name, say, "score". Then the path to compTotal would be _root.score.compTotal.
    I'll see if I can get the rest to work. But maybe someone else will too.

  3. #3
    Junior Member
    Join Date
    Oct 2001
    Posts
    10
    thanks for looking at it. the variable for the score test is called that because it directly references the compTotal variable in frame 1 of the main timeline.

    in order to make it easier to follow through the movie this is a rough order...

    roll button -> control clip -> dice generate the numbers based on the random frame they're sent to (updating compTotal variable -> score clip

    hope this helps!

  4. #4
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514
    Ok, yeah. I realize I didn't look at it closely enough. Still, I wouldn't put "_root" as the name of a variable. It's a path, not a name.
    However, here's something simple that may help:
    try setting the compTotal var back to zero when the user clicks 'retry'.
    That way it's always using your function from its starting point, rather than incrementally adding on to it.
    Or am I an idiot and not seeing the big picture?

  5. #5
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514

    OOPS

    Wait. . . that sometimes doesn't work, either.
    I see what's happening. . . sometimes one of the dice doesn't get counted in the total. You'll notice that when there's an error, the value is based on one of them, but not the other. It needs to calculate both at once.
    What I'm thinking is maybe you should take the actions off the frames in the dice and put it in a clipEvent (enterFrame)-
    Then say if frame=="six", add to score, etc. etc. Maybe the enterFrame will force it to calculate both.

  6. #6
    Junior Member
    Join Date
    Oct 2001
    Posts
    10
    thanks again...

    if you look at the actionscript on frame 1 of main movie, the variable does get reset to 0 each time.

    i understand what you're saying about only 1 dice being calculated sometimes but the key is SOMETIMES! the reason that i named this thread "...restore my faith" etc is because i can't see WHY the error only occurs sometimes. i could perhaps fix it using another method but until i can understand what's wrong with this one it will bug me for evermore!!!

    i really appreciate your work on this...perhaps we can come up with a reason!!! (or someone else might know!!)

  7. #7
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514
    Yes, your action sets the variable to 0 initially, but then it gets updated.
    That's why I had it re-set to 0.
    Sending the play head back to frame one, won't automatically update the variable back to 0 I don't think.
    When you put a variable on a frame and then update it, the frame stores the new value.

  8. #8
    Junior Member
    Join Date
    Oct 2001
    Posts
    10
    well, i have admitted defeat and tried a more sensible way...

    http://members.aol.com/gilbertgbert/dietest3.fla

    bah humbug!!!!

    swf is here...

    http://members.aol.com/gilbertgbert/dietest3.swf


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center