The DynLayer can be applied to any layer using this general format:
objectName = new DynLayer(id,nestref)
Simple Layer Example:
Let's say you have a very simple layer with this structure:
<STYLE> #mylayerDiv {position:absolute; left:30; top:50;} </STYLE> <DIV ID="mylayerDiv"></DIV>
To initialize 'mylayerDiv', your javascript will be:
mylayer = new DynLayer('mylayerDiv')
Notice how I append the 'Div' extension on the ID of the layer. I do this is because the name of the object cannot be the same as the ID of the layer. It's just a nice way to keep your variables separate.
Nested Layer Example:
<DIV ID="myparentDiv"> <DIV ID="mylayerDiv"></DIV> </DIV>
To initialize 'mylayerDiv':
mylayer = new DynLayer('mylayerDiv','myparentDiv')
Notice the name of the parent layer is passed for the nestref argument.
Multiple Nesting:
<DIV ID="myparent1Div"> <DIV ID="myparent2Div"> <DIV ID="mylayerDiv"></DIV> </DIV> </DIV>
If the layer is nested multiple times you must pass the names of all layers in that hierarchy separated by '.document.':
mylayer = new DynLayer('mylayer','myparent1Div.document.myparent2')
Initialization Demo:
View dynlayer-initialization1.html for an example showing various initializations.
Also Read: DynLayerInit() Function which you can call to automatically define DynLayers.
Home | Next Lesson: Geometric Objects |