Clone method for Object2D?

How can I clone Object2Ds?

I cannot seem to get the positioning correct. The non-cloned version is fine but the ‘cloned’ instance looks. The cloned instances seem to have the correct position until I move it with my mouse. If It take out the clone then it works fine.

Maybe somebody could share there knowledge on Object2D or share there own code?

This is my code (I will add support for more types of Object2D when I require them):

[code]Function CloneGroup(extends g as Group2D) As Group2D
dim clone as new Group2D
clone.x = g.x
clone.y = g.y
clone.Rotation = g.Rotation

for i as integer = 0 to g.Count - 1
clone.Append(g.Item(i).Clone)
next

return clone
End Function

Function Clone(extends o as Object2D) As Object2D
dim clone as Object2D

//clone original object
select case o
case isa PixmapShape
clone = new PixmapShape(PixmapShape(o).Image)
case isa Group2D
clone = Group2D(o).CloneGroup
case else
raise new UnsupportedFormatException
end select

clone.x = o.x
clone.y = o.y
clone.Rotation = o.Rotation

return clone
End Function
[/code]

Thanks

BUMP