Page 1 of 1
Script for setting the script of a object
Posted: Sat Nov 29, 2014 9:17 am
by montymay
Maybe I'm overlooking something obvious, but the following script does not seem to do anything:
Code: Select all
on mouseup
set the script of grc GRAPHIC_NAME_A to the script of grc GRAPHIC_NAME_B
end mouseup
GRAPHIC_NAME_A and GRAPHIC_NAME_B are either the actual names of the objects, in quotation marks, or are variables that contain the actual names. When I open the script for the second object after running both versions of the script, the script of the second object is empty. Thank you for any suggestions.
Monty
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 9:27 am
by Dixie
I have just done more or less the same to test... 2 graphics, then in the script of a button :-
Code: Select all
on mouseUp
set the script of grc 2 to the script of grc 1
end mouseUp
This works for me...
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 10:04 am
by montymay
Thanks, Dixie. Your script is in the same form as mine, and both our scripts track the example for the command in the Dictionary. I even created graphics named 1 & 2 and used your script verbatim, but the script of grc 2 remains empty. I'll keep trying but welcome other suggestions.
Monty
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 10:13 am
by SparkOut
I have heard someone mention similar a long time ago, and it turned out the script was there but just not visible in the editor, due to some rendering problem. (Maybe linked to the reason why copy/pasting code from other sources eg web page doesn't work???)
Saving the stack, closing lc and opening again showed the script in place. Worth a try?
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 11:03 am
by jmburnod
Hi All,
Strange
Dixie's script works for me with LC 5.5,6.7,7, and community 6.1
Best regards
Jean-Marc
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 4:38 pm
by jacque
Do you have more than one graphic with the same name? The script may be setting a different one than you expect.
Also, iuf the graphics have numbers for names without any alpha characters then the engine is very likely to choose the graphic with that layer number rather than the one with the numeric name. Never name objects with numerals only, always include at least one alpha character.
Re: Script for setting the script of a object
Posted: Sat Nov 29, 2014 4:40 pm
by FourthWorld
SparkOut wrote:copy/pasting code from other sources eg web page doesn't work
UTR - Recipe?