A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 43

Thread: Betting randomizer trotting

  1. #21
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    edit to the text above (I did not make the 60minutes limit for this edit):

    (simplifying instructions -
    1. enter in editbox häst 1 E 2 and K 2 and häst 2 E 2 and K 2 only
    2. then press the button at bottom right(beräkna...) and see the result in the editboxes in the top right(winner) and middle right(runner up), the editbox that shows up below the pushbutton(beräkna...) displays the array content 1,1,2,2 and the winners number should have been erased from there)

  2. #22
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Quote Originally Posted by SirN
    (I'm using 3DFA v4.9.6.8 latest version that is)
    arrayname.removeAll (winninghorsevariable) // fixed it problem solved

    I hope I did not bother you! Complete script for picking runner up (and third place with rewrite)below:

    toNumber (vinnareblir);
    slumpklump.removeAll (vinnareblir);
    longness = slumpklump.length;
    mellansteg2 = Math.floor(Math.random()*slumpklump.length);
    tvaablir = slumpklump[mellansteg2];

    Current version http://web.comhem.se/~u53935741/kjellboy4968v093.html only lacks functionality on the wildnessfactor!
    Last edited by SirN; 09-25-2007 at 05:14 AM.

  3. #23
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Quote Originally Posted by SirN
    All I can do now is to promise that I will create an English language version when done, both source and exported for all to use!
    The swedish version is completely done, here http://web.comhem.se/~u53935741/kjellboy4968v10b.html it will take a while before I translate it.

  4. #24
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Quote Originally Posted by SirN
    The swedish version is completely done, here http://web.comhem.se/~u53935741/kjellboy4968v10b.html it will take a while before I translate it.
    I have discovered that it doesn't work properly, and I know where it fails. Look at this:
    if (vildhet > 4 && vildhet < 15 && fas4 > 89 && fas4 < 110) // vildhet 5-14
    {
    dragg = 3.6;
    }
    if (vildhet > 4 && vildhet < 15 && fas4 >= 80 && fas4 <= 89)
    {
    dragg = 2.9;
    }

    I'm passing the variable vildhet and the variable fas4 over to this functionscript and I want to recieve the variable dragg from this function. The problem is this : if (vildhet > x && vildhet < x && fas4 > x && fas4 < x) as an criteria - it's not understood by the 3DFA... If I could split it it would work, like this: if ( vildhet > x && vildhet < x)
    {
    dragg = x; }

    The question is how I can get both criterias work? Is this possible:
    if ( vildhet > x && vildhet < x ; fas4 > x && fas4 < x) { dragg = x; }

    I wonder if that semicolon between vildhet and fas4 will make a difference and will test it later (I dont have time now)...

  5. #25
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    I'm pretty sure that multiple criterias work ok..

    I tested your code in preview and flash and it worked right... you need to add more debugging, something other fails, not multiple conditionals..

    (add one edit box that has "db variable")

    Code:
    var v  = 10;
    var f = 95;
    var db;
    
    testabc(v, f)
    
    
    function testabc(vildhet, fas4) {
    
    var dragg;
    
    if (vildhet > 4 && vildhet < 15 && fas4 > 89 && fas4 < 110) // vildhet 5-14
    {
    dragg = 3.6;
    trace ("dragg = 3.6");
    db = "dragg = 3.6";
    }
    if (vildhet > 4 && vildhet < 15 && fas4 >= 80 && fas4 <= 89)
    {
    dragg = 2.9;
    trace ("dragg = 2.9");
    db = "dragg = 2.9";
    }
    
    }
    Last edited by Finjogi; 01-20-2008 at 01:03 PM.

  6. #26
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    [QUOTE=Finjogi]I'm pretty sure that multiple criterias work ok..

    I tested your code in preview and flash and it worked right... you need to add more debugging, something other fails, not multiple conditionals..

    (add one edit box that has "db variable")

    QUOTE]

    Yes, thanks for reminding me, I have now used trace at various places and investigated it further - with some success... First of all I must tell you that I use 3DFA v 3.9.6.8 and that version has a lot of problems with sticking to variable types ( e.g. an integer value in a variable gets handled as text in other places), I use a lot of toNumber (variablename) to hold on to the number that I place in the variable. And, if I shift to later versions of 3DFA that toNumber shows up as errors because it was probably bugs fixed and it's a mess - if I fix it (a lot of work to fix it I think) then I might need to work around bugs in the latest version of 3DFA that are fixed in the next version and I would need to rewrite it all for the latest version again - and I dont want to do that... I have it almost working in 3.9.6.8 and I will stick to that version for the duration!

    Enough said about that, phew!

    I have found out that the starting script plays a big role. If I initiate var vildhet = 35; there then when the movie displays an editbox connected to the variable vildhet and I change the number in that box then it still works with what is said at the starting script! E.g. I start the movie and enter 1 in the vildhet editbox then I trace the vildhet variable and it sais it is 1 but anyway it uses the 35 number from the starting script and dragg is picked up from vildhet 35!

    If I take away the number from the starting script and just say var vildhet; there and go on then it doesnt use it althought trace sais vildhet is 1 and dragg is not picked up from anywhere...

    Totally amazing! It's like the vildhet variable must be set in the startscript/moviescript:
    Code:
    var vildhet = 35;
    At the press of a button (after editing the vildheteditbox - changing the vildhet variable):
    Code:
    if (vildhet = 35 && fas4 > 89) // vildhet 35
    			{
    				dragg = 4.0;
    				dumdum = 35.1; // this variable is a debug tracer
    				}
    dragg is picked up and can be used in calculation with above (when fas4 is above 89) and also
    Code:
    if (vildhet = 35 && fas4 >= 80 && fas4 <= 89)
    			{
    				dragg = 3.0;
    				dumdum = 35.2; // debug tracer
    				}
    works if fas4 is between 80-89

    and if moviescript/startscript sais:
    Code:
    var vildhet = 1;
    then dragg is picked up correctly from this:
    Code:
    if (vildhet >= 1 && vildhet < 5 && fas4 > 89) // vildhet 1-4
    			{
    				dragg = 4;
    				dumdum = 1.1;
    				}
    if fas4 is above 89

    BUT dragg is not picked up from here:
    Code:
    if (vildhet >= 1 && vildhet < 5 && fas4 >= 80 && fas4 <= 89)
    			{
    				dragg = 3.0;
    				dumdum = 1.2;
    				}
    when fas4 is 88

    Soo, 2 problems exist!
    1. The variable vildhet is only existing in 3DFA from the starting/movie-script and even if that variable has an editbox and changes are made and trace displays the changes, it still uses the number from the starting/movie-script.
    2. The criterias vildhet between x and x together with fas4 between x and x is problem

    I'm grateful for any suggestions and I will dig deeper into this tomorrow!
    Last edited by SirN; 01-20-2008 at 08:01 PM.

  7. #27
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Quote Originally Posted by SirN

    First of all I must tell you that I use 3DFA v 3.9.6.8 and that version
    ...
    Soo, 2 problems exist!
    1. The variable vildhet is only existing in 3DFA from the starting/movie-script and even if that variable has an editbox and changes are made and trace displays the changes, it still uses the number from the starting/movie-script.
    2. The criterias vildhet between x and x together with fas4 between x and x is problem
    Version makes a great difference.. What I can suggest to minimize version problems is to use last version that uses earlier codebase... and I'm not sure which one is that...

    About problems & workarounds..
    1. sorry, I dont have 3.xx version where to test that..
    2. workaround: You could try to separate criterias to 2 nested if's
    Code:
    if(aaa>70 && aaa<80){
      if(bbb>1 && bbb<16){
        // both criterias true...
      }
    }

  8. #28
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    I wrote wrong, I use version 4.9.6.8 not 3xxx, sorry!

    I will test to separate it soon.

  9. #29
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    I have stepped up to 3DFA 4.9.7.9 and have it working (malfunctioning like before in the 2 criterias but I havent tried your solution yet) by erasing a lot of toNumber commands and adding som :int declarations to variables.

    If you want to check this source I include it (you wont understand much of the swedish but anyway) the instructions needed is:
    1. Run the movie
    2. Enter 99 for horse 1 in both the E and the K box
    3. Enter 1 in the horse 2 E box only
    4. Enter 1 in the horse 3 E box only also
    5. Enter the number 1 or 35 in the vildhet box
    And voila, it works great (tracing with the dumdum) But if you enter 88 in both boxes for horse 1 then it only works when vildhet is 35... The .movie is here http://web.comhem.se/~u53935741/kjellBoy4979v098.zip

    The script in the element functions only handles the placefinish tick box and the big script is at the KlarTextButton element (its in KlarTextButton script I have the works). Also, the 1st problem that the vildhet variable only was used from the moviescript is fixed with this new 3DFA it seems to work better.
    Last edited by SirN; 01-21-2008 at 05:06 PM.

  10. #30
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    I'm about to send ts away as a bugreport, your workaround to split the 2 criterias down has failed. Both this:
    Code:
    if (vildhet >= 1 && vildhet < 5) // vildhet 1-4
    			{
    			if (fas4 > 89) 
    				{
    					dragg = 4.0;
    					dumdum = 1.1;
    					}
    			
    				}
    		if (vildhet >= 1 && vildhet < 5) 
    			{								
    			if (fas4 > 79 && fas4 < 90)
    				{
    					dragg = 3.0;
    					dumdum = 1.2;
    					}								
    				}
    and this:
    Code:
    if (vildhet >= 1 && vildhet < 5) // vildhet 1-4
    			{
    			if (fas4 > 89) 
    				{
    					dragg = 4.0;
    					dumdum = 1.1;
    					}
    			
    			if (fas4 > 79 && fas4 < 90)
    				{
    					dragg = 3.0;
    					dumdum = 1.2;
    					}							}
    fails when fas4 is between 80-89 - the dragg is not picked up correctly! Instead when vildhet is 1 and fas4 is 88 the dragg is picked up from here:
    Code:
    if (vildhet = 35 && fas4 >= 80 && fas4 <= 89)
    			{
    				dragg = 1.0;
    				dumdum = 35.2;
    				}
    which is an remarkable event

    Maybe , well I don't know, how can it take the dragg from that place when it has vildhet at 1? Why does it believe that vildhet is 35 when fas4 is set to 88 when it uses vildhet set to 1 if fas4 is 99? It must be strange to anyone! (I have updated the .zip at http://web.comhem.se/~u53935741/kjellBoy4979v098.zip )
    Last edited by SirN; 01-22-2008 at 12:17 AM.

  11. #31
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Quote Originally Posted by SirN
    Instead when vildhet is 1 and fas4 is 88 the dragg is picked up from here:
    Code:
    if (vildhet = 35 && fas4 >= 80 && fas4 <= 89)
    			{
    				dragg = 1.0;
    				dumdum = 35.2;
    				}
    which is an remarkable event

    Maybe , well I don't know, how can it take the dragg from that place when it has vildhet at 1?
    I have not yet looked your zipped movie but at least one bug found in above code if it is not typo.. -> vildhet = 35 -> which makes it 'true' so no wonder it goes there and might mess more things because vildhet in after that 35...

  12. #32
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    There you have it, good, problem solved - this betting randomizer is completely a product of good support and help from this forum! I did a quick change to:
    Code:
    if (vildhet > 34 && vildhet < 36 && fas4 >= 80 && fas4 <= 89)
    			{
    				dragg = 1.0;
    				dumdum = 35.2;
    				}
    and voila, fas4 88 and vildhet 1 picked up the dragg from the right place, soo, it was picking it up from two places making the latter the current before! I don't understand how vildhet = 35 can become true as you say, but that is irrelevant when I have the cure for it all!

  13. #33
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Thats programming basics, but quite easy to happen even if you are more experienced coder
    vildhet = 35 sets vildhet to 35 and same time it acts as logic in if...

    if(vildhet==35..... is the proper way to compare..

    Accidental assignment/Accidental Booleans
    if(a=b) c; /* a always equals b, but c will be executed if b!=0 */
    Depending on your viewpoint, the bug in the language is that the assignment operator is too easy to confuse with the equality operator; or maybe the bug is that C doesn't much care what constitutes a boolean expression: (a=b) is not a boolean expression! (but C doesn't care).
    This is for C language but some mistakes can be made in as3/c# scripts..
    http://www.andromeda.com/people/ddyer/topten.html

  14. #34
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Quote Originally Posted by Finjogi
    Thats programming basics, but quite easy to happen even if you are more experienced coder
    vildhet = 35 sets vildhet to 35 and same time it acts as logic in if...
    Now understood! Darn -I just discoverred the movie does not work at all when exported... Big upset!

    I've run into another problem which occours the second time the KlarTextButton is pressed. It's about the 'checkbutton' functionallity, and a little difficult to explain... I try anyway.

    This movie picks by random the winner, runnerup and third place finisher in the horse race by using an array filled with the horse numbers. The amount of horse number in the array depends on the values you enter and the tick in the checkbox called P for every horse. If 99 is enterred in the E and the K editbox and 35 stands in the vildhet editbox that horse gets 99 spots in the array - simple? Another horse would get it's amount of spots in the array depending on it's E and K values. But by checking the P checkbox I add a little to the horse and give it more slots in the array. And it all works well allready the first time over. E. g. if I enter 99 and 99 for horse 1 and something for 2 other horses it's ok and I see the correct amount of slots the first horse gets - then I tick the checkbox and it works ok and the amount of slots for horse 1 is a little more - but then if I uncheck the box and try again it is not working. It's like if I have ticked the P box for the horse it cannot be unticked.

    I update the .movie in the zip and if you run the movie you can watch the trace.
    First trace is for E and K added then divided by 2 for horse 1
    Second trace is for first trace adjusted by the place tickbox for horse 1
    Third trace is for the dragg value for horse 1
    And forth trace is for the amount of spots horse 1 gets

    If I enter Horse 1 E 99 K 99 and not check the box and leave vildhet at 35 (I must add numbers for 2 more horses also) the 4 traces show 99 99 1 99 which is correct, and if I do the same and check the box then the 4 traces show 99 109 1 109 which is also correct, but then the problem occours when I uncheck that box ( I would want it to revert back to 99 99 1 99 off course ) because the trace still shows 99 109 1 109 as if the checkbox were ticked. I use this code for the checkbox:
    Code:
    if (platstick1 == true)
    	{
    	fas2 = fas2h1;
    	platstab(fas2);
    	fas3h1 = fas2h1 + platsjustering;
    	fas4h1 = fas3h1 / 2;
    		}
    else if (platstick1 == null) 
    	{
    	fas4h1 = fas2h1;
    		}
    As you can see, if platstick is true I want fas2h1 turned adjusted into fas4h1 and if platstick is null ( it is neccessary to use null for some reason - if I use false it doesnt work at all ) then fas2h1 also turns into fas4h1 without beeing adjusted.

    Why does the movie see the checkbox unticked once and then ticked once but then acts like it is ticked when it's not the third time I press the button? Can I rince all calculations or reset in some way?
    Last edited by SirN; 01-22-2008 at 03:41 AM.

  15. #35
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    As mentioned, my movie completely malfunctions when exported. And I had this problem in the past and it was a case of 3DFA allowing and handling an floatingpoint number as an integer making the number flat - and when exported the flash 8 as2 did not work as kind as 3DFA - soo the solution were to write Math.floor for the variable...

    Now I have used Math.floor at all places where it can be needed and still the movie don't work when exported! Am I using Math.floor wrongly if my code sais:
    Code:
    spotsh1 = Math.floor (fas5h1);
    BTW I will switch to Math.round because it suits me better I think...

    Can someone look at the source .movie and see why it plays ok internally but not exported? The exported is at http://web.comhem.se/~u53935741/kjellboy4979v098.html and the source is at http://web.comhem.se/~u53935741/kjellBoy4979v098.zip

    Instructions needed is:
    1. fill in some numbers for häst 1 (horse 1)
    2. also for at least 2 more horses (numbers above 10 please)
    3. Press the button (the button is element KlarTextButton and it holds the script that might be a problem)
    Last edited by SirN; 01-23-2008 at 12:55 AM.

  16. #36
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    I have to look your code more when I get back to home but NaN in editboxes tells me that somewhere there is a string used in calculations.. Best way to get rid of these errors is to really define all used variables to types what are used for. That way even a flash9 export goes well.
    Anyway, I'll check more of your code later..

    edit: little debug printing in flash -> "dragg" seems to be "undefined" so it seems getdragg() does not work and set "dragg" variable..
    Which makes NaN in calculations where "dragg" is used.
    Last edited by Finjogi; 01-23-2008 at 05:11 AM.

  17. #37
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Quote Originally Posted by Finjogi
    edit: little debug printing in flash -> "dragg" seems to be "undefined" so it seems getdragg() does not work and set "dragg" variable..
    Which makes NaN in calculations where "dragg" is used.
    Yes, I thank you for taking some time to look at this, and after a little thought I figured your comments are about the exported, and it makes sence that I don't understand at all how to find that out and neither how to deal with it ...

    The last working export is here(using 3DFA 4.9.6.8):
    http://web.comhem.se/~u53935741/kjellboy4968v096.html

    The only thing bad about it is that I had not gotten the vildhet% to work, and it was fixed when we discovered that the code was wrong at 35%:
    Code:
    if (vildhet = 35 && fas4 >79 && fas4 < 89)
    was wrong and easilly fixed... Maybe I should switch back to that working export and fix it up... ? At least I might trace where the export stops working if I do...
    Last edited by SirN; 01-23-2008 at 04:02 PM.

  18. #38
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    I have gone back to 4.9.6.8 and gotten it exported working at:
    http://web.comhem.se/~u53935741/kjellboy4968v10b.html everything works ok (except for the checkbox which after beeing clicked stays clicked in the mathematics)

    I will edit the .movie and switch from Math.floor to Math.round in various places and I will edit other things but it is ok as an beta from now on! Use it to bet with an randomizer!

    I will also study a bit if I can go to the newer 3dfa to get it exported there but I am happy to have it working in this older version... If you want to see the working beta source for 4.9.6.8 it is here:
    http://web.comhem.se/~u53935741/kjellBoy4968v10b.zip and the malfunctioning 4.9.7.9 source is still here:
    http://web.comhem.se/~u53935741/kjellBoy4979v098.zip

  19. #39
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    I have discoverred that the 4.9.7.9 source not only works great internally but also works great as an executable. I have mailed support about why?

    Malfunctioning Flash8export source is here (somewhat stripped from last time):
    http://web.comhem.se/~u53935741/kjellBoy4979v098.zip

  20. #40
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    (This you wont believe, but anyway)

    The premiere use of the fully functioning betting randomizer ended in success! The bet was just USD1.40 for 2 horses to finish 1st and 2nd and it gave a total win of USD14, it was great anyway! I cannot believe it myself, almost.

    Great fun! Talk about a good debute for using it!

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