Hi peoples...
I have a task where I need to change the parent of
a layer
I have four layers
Layer BASE
Layer A
Layer B
Layer X
Layer BASE is child of DynAPI.document
Layer A and B are children of BASE
Layer A has a child, layer X
Layer X is draggable
Layer B has no children
On dragstart, I want to make Layer X a child of
BASE (so it can 'move'
freely in BAE and seemlessly to LayerB across the
way.
and the if the Layer X is dropped onto Layer B..
make it s a child of Layer B.
As soon as I removeChild(layerX) from layerA ..
the child disappears .. the next line is always to
layerBASE.addChild(layerX)
in this example addChild implicityly removes' the
child
from it's parents (tried many things .. this is
just one of them)
but it never comes back ...
Here is some sample code...
myListener=new
EventListener(this)
myListener.ondragstart=function(e)
{
layerX=e.getTarget() layerBASE.addChild(layerX); } myListener.ondragend=function(e)
{
layerX=e.getTarget() layerB.addChild(layerX); // addChild implicitly calls
// removeChild on
the
// obj anyway (see
dynapi.js)
} } layerX.addEventListener(myListener) Has anybody done this
before ? got a working example ? My ultimate goal is to
change the parent of a
given layer.and not have the layer disappear.
- ramon
|
- Re: [Dynapi-Help] Changing a layers parent. R & S Buckland
- Re: [Dynapi-Help] Changing a layers parent. R & S Buckland