Page 1 of 1

Changing button-icons via script?

Posted: Sun May 15, 2011 6:32 pm
by Tomka
Hello,

I got a little script-problem. There are 2 buttons "Man" and "Woman"... if you click on one, it will be highlighted and the icons of the other button shall be changed.

Script of the first button (named: "Button_mann_0") :

Code: Select all

global g_neueperson_sex

on mouseUp
   if g_neueperson_sex<>"mann" then //checks if its allready activated
      put "mann" into g_neueperson_sex
      set the icon of the btn "Button_frau" to ID 10012
      set the hovericon of btn "Button_frau" to ID 10013
       set the armedicon of btn "Button_frau" to ID 10012
   end if
end mouseUp
The id´s refer to pictures on an other substack, where I imported the pictures as controls. If i push the button, following error appears:
button "Button_mann_0": compilation error at line 6 (if: not a command) near "10012", char 48
Maybe important: The buttons are on a seperate substack which is opened via filepath during execution. (Want to be able to save this substack later in a file)

Thanks for help :)

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 6:37 pm
by dglass
The dictionary has this:

set the hovericon of button "Play" to 210095

there is no 'ID', perhaps that is the problem?

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 6:47 pm
by doc
Since you are storing the images in a different stack, I'm pretty sure that the error indicates that the engine cannot locate your image... so try something like this:

Code: Select all

set the icon of the btn "Button_frau" to 10012 of stack "otherstackname"
HTH,
-Doc-

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 7:04 pm
by Tomka
I tried:

Code: Select all

global g_neueperson_sex

on mouseUp
   if g_neueperson_sex<>"mann" then
      put "mann" into g_neueperson_sex
      set the icon of the btn "Button_frau" to image "weiblich_button_0.png" of stack "Untitled 2"
      set the hovericon of btn "Button_frau" to  image "weiblich_button_1.png" of stack "Untitled 2"
      set the armedicon of btn "Button_frau" to  image "weiblich_button_0.png" of stack "Untitled 2"
      
      set the icon of me to image "männlich_button_1.png" of stack "Untitled 2"
      set the hovericon of me to  image "männlich_button_0.png" of stack "Untitled 2"
      set the armedicon of me to  image "männlich_button_1.png" of stack "Untitled 2"
      
   end if
end mouseUp
Theres no error but if I push the button the buttons will be invisible. The property manager says icon-property = "0" and so on... Doesnt work it seems, other ideas? :)

Edit: In the property manager I can use the IDs to change the icons. So it shouldnt be a problem that pictures are on an other substack.

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 7:10 pm
by doc
Go back to the version using the icon ID (10012) but without actually adding the "ID" as dglass indicated...
...but adding a reference to the stack where the image is located, as shown in my example.

-Doc-

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 7:18 pm
by Tomka
No errors, no changes when i push the button.

Think that will be to complicated. I ll use 2*2 buttons and use visible/invisible :)

Re: Changing button-icons via script?

Posted: Sun May 15, 2011 9:14 pm
by Klaus
Hi Tomka,

do this:
...
set the icon of the btn "Button_frau" to THE ID of image "weiblich_button_0.png" of stack "Untitled 2"
...

Best

Klaus