Was looking for a little help on how I can add code to a dynamically created object in livecode.
In Lingo I could do the following to add an object then add code to it. Sorry for the [dot] but this forum does not let me post using dot syntax lingo code.
tNewMem = new(Object)
tNewSprite = sprite(spriteNum)
tNewSprite[dot]puppet = true
tNewSprite[dot]member = tNewMem
sprite(spriteNum)[dot]scriptInstanceList[dot]add(Script Reference)
What would a script look like to do this in livecode if it is possible?
Lingo alt to adding code to an object at runtime
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
Re: Lingo alt to adding code to an object at runtime
Hi CenturyMan1979,
geeez, I immediately abandoned Director when the first version of MetaCard (the grandfather of LiveCode)
for Mac/Win came out and before I dived into the Director OOP stuff in 1999
You can add a "behavior", which is "just" the script of a "premade" button, to newly created objects:
...
create button
## or field or player or graphic or whatever you like to create
## No "sprites" or "puppets" in Livecode!
set the behavior of last button to the long ID of btn "the premade behavior button here..."
...
Yep, something like this
And welcome to the forum!
Best
Klaus
geeez, I immediately abandoned Director when the first version of MetaCard (the grandfather of LiveCode)
for Mac/Win came out and before I dived into the Director OOP stuff in 1999
You can add a "behavior", which is "just" the script of a "premade" button, to newly created objects:
...
create button
## or field or player or graphic or whatever you like to create
## No "sprites" or "puppets" in Livecode!
set the behavior of last button to the long ID of btn "the premade behavior button here..."
...
Yep, something like this
And welcome to the forum!
Best
Klaus