Wow, I'll try to answer this question from the future (a slight 
adjustment of your system clock might be in order).

Assume that you have a parent script named "Foo".  And that you 
already have a Foo object that you have instantiated by something 
like this:

FooObject1 = new(script "Foo")

Now you want to create a clone of this object - in effect create 
another Foo object witht the same property values.  Here is a routine 
that will do that:

on CloneObject oFrom, oTo  -- object From, object To
   nParams = count(oFrom)
   repeat with paramNum = 1 to nParams
     symParam = getPropAt(oFrom, paramNum)
     theValue = getAProp(oFrom, symParam)
     if listp(theValue) then
       theValue = duplicate(theValue)
     end if
     setAProp(oTo, symParam, theValue)
   end repeat
end CloneObject

(This takes advantage of the fact that the properties of an object 
can be thought of as a property list.)

To use it, you need to create a new Foo object, then call this 
routine passing in the two object references:

FooObject2 = new(script "Foo")
CloneObject(FooObject1, FooObject2)

Note that this will only work correctly if the Foo parent script does 
NOT create any objects itself.  If your parent script does that, then 
I'll leave that as "an exercise for the reader".

Enjoy,

Irv

At 5:13 PM +0200 7/23/03, Pascal Deraed wrote:
>hi!
>How do i duplicate a child object?
>
>thanks in advance..
>/pas
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to