Hi I am trying to assign a behavior to a dynamic created graphic but get the following error:
execution error at line n/a (parentScript: bad object) near "graphic id 1109 of card id 1002 of stack "codelibrary" of stack "/Users/theovanstratum/Documents/ProjectX/workflow test.livecode""
The code that assigned the behavior is this:
case "Task"
add 1 to lTaskCounter
put "Task" & lTaskCounter into gName
create graphic gName
set the opaque of graphic gName to true
set the backgroundColor of graphic gName to "white"
set the width of graphic gName to 100
set the height of graphic gName to 50
set the showName of graphic gName to true
set the location of graphic gName to the mouseLoc
set the behavior of graphic gName to the long id graphic id 1109 of card id 1002 of stack "codelibrary"
break
and is part of a popup menu.
The graphic on the card in the substack "codelibrary" exists and the code in there work if I access it on the substack.
Any ideas what I do wrong?
Thanks
Dynamic assigning behaviors
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Dynamic assigning behaviors
Hi theo,
only BUTTONS can "hold" a behaviour!
Every other objects "just" has a script, but you cannot assign a script to another object
due to some runtime restrictions (check "script" in the docs).
So put the script of your "graphic id 1002 of card id 1002 of stack "codelibrary"" into a button
and THEN you can assign a behaviour to new objects.
Hint you also should add OF:
...
set the behavior of graphic gName to the long id OF graphic id 1002 of card id 1002 of stack "codelibrary"
...
Best
Klaus
only BUTTONS can "hold" a behaviour!
Every other objects "just" has a script, but you cannot assign a script to another object
due to some runtime restrictions (check "script" in the docs).
So put the script of your "graphic id 1002 of card id 1002 of stack "codelibrary"" into a button
and THEN you can assign a behaviour to new objects.
Hint you also should add OF:
...
set the behavior of graphic gName to the long id OF graphic id 1002 of card id 1002 of stack "codelibrary"
...
Best
Klaus
Re: Dynamic assigning behaviors
Hi..
Set your behavior to a button, you have to use a button to hold the behavior.. as in ( from the example in the dictionary).
be well
Dixie
Set your behavior to a button, you have to use a button to hold the behavior.. as in ( from the example in the dictionary).
Code: Select all
set the behavior of tNewGroup to the long id of button "Widget" of card "Behaviors"
Dixie
Re: Dynamic assigning behaviors
Hi,
Behaviors can only be set to the long id of a button, not a graphic.
Kind regards,
Mark
Behaviors can only be set to the long id of a button, not a graphic.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 7
- Joined: Wed Dec 21, 2011 10:42 am
Re: Dynamic assigning behaviors
Thanks all, I had found it and it works