dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: CheckButton reset, how?

  1. #1
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142

    CheckButton reset, how?

    I use checkbuttons in my creation (much help from you here almost makes it our creation).

    I have nothing, no script on them, but I use it in another place like this (platstick1 is 'Expression' of the checkButton):

    Code:
    if (platstick1 == true)
    	{
    	fas2 = fas2h1;
    	platstab(fas2);
    	fas3h1 = fas2h1 + toNumber (platsjustering);
    	// Här tog jag bort en multiplikation - platstick adderar mellan 20-29 i skala om 10
    	// 
    	fas4h1 = fas3h1 / 2;
    		}
    And when I run the app. if I press the first checkbutton it adjusts the fas2h1 number into fas3h1 (a little to the side of the question that I want to address). The problem is that if I press the checkbutton and run the random pick of the winner once and then uncheck the checkbox and change all numbers then the script treats the checkbox as pressed even if it is not. The working example of the problem is here http://www.sdax.se/travsidan/kjellboy1.htm and instruction (fast and simple):
    1. Enter 99 and 99 for Häst 1 and 2 and 3 and DON'T tick any checkboxes
    2. Press the button on the screen and the program picks the winner (either 1,2 or 3 gets picked) Observe the BOLD numbers next to the tickboxes (they will say 99 for all 3 horses)

    3. Tick the checkbox for Häst 1
    4. Press the button. Observe the BOLD numbers next to the tickboxes (they will say 109 for Häst 1 and 99 the others) (That means that when you have pressed the checkbox you have given that horse a little better chance to get picked by the random, the bold numbers are the amount of slots it gets in the array were the random picks from)

    5. Untick the checkbox next to Häst 1
    6. Press the button. Observe the BOLD numbers next to the tickboxes (they will say 109 for Häst 1 and 99 for the others)

    That is the problem!! When the tickbox is unchecked the situation should return to the numbers after the first press of the button.

    My hunch tells me that I should add a scriptcode at the checkbox, like under the 'Button On' -tab platstick1 = true

    and on the 'Button off ' -tab platstick1 = false

    Does that sound ok to you?

  2. #2
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    Yes, that will surely solve your problem. Using ActionScript is usually the best solution for problems with built-in elements. I often had problems with buttons and checkboxes.

  3. #3
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    No, it did not help to add a script at the checkbutton 'ButtonOn' and 'ButtonOff' I solved it another way. Checkbuttons work automatically as 'True' or 'False' on the expression (in my case 'platstick1') - I had an error at another place in my code, see the error here:
    Code:
    if (platstick1 == true)
    	{
    	fas2 = fas2h1;
    	platstab(fas2);
    	fas3h1 = fas2h1 + toNumber (platsjustering);
    	// Här tog jag bort en multiplikation - platstick adderar mellan 20-29 i skala om 10
    	// 
    	fas4h1 = fas3h1 / 2;
    		}
    else  if (platstick1 == false) 
    // här var det nödvändigt att ta bort 'if (platstick1 == falsel)'
    // efter den här förändringen fungerade platsreset
    	{
    	fas4h1 = fas2h1;
    		}
    		// här under kommer vildhetsdelen
    fas4 = fas4h1;
    The code is about creating fas4h1 either when platstick1 is true or false and in 3DFA 4.9.6.8 if I just erase 'if (platstick1 == falsel)' it worked.

    Problem solved!

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