The reason for DynAPI to create the layer/div is to make it easier.  There's nothing 
stopping you from creating your layers manually, and then attaching them to a DynLayer 
afterwords like so:

<div id='mylayer'></div>
<script>
d = new DynLayer();
d.setID('mylayer');
d.assignElement(is.ie?document.all.mylayer:document.layers.mylayer);  // assignElement 
is re-introduced in 2.6
</script>

In the current paradigm, creation works similarly to Java does.  You create a GUI 
object, and add that to some other object.  Dynlayer needs to know what object to be 
created in, be it another layer, or the document.  It wouldn't be a good idea for the 
constructor to create the browser element (during "new DynLayer()") because it would 
have to be created again when you add it to another layer (nesting).  And things have 
been optimized so that the layer is only created when all it's size/location/color has 
been finalized so to reduce unneeded processing.

Regards,
Dan Steinman


On Fri, Nov 09, 2001 at 11:32:31PM +0000, Quang Nguyen wrote:
> I guess we create a DynAPI object to make sure the Dynapi.js and any library 
> needed have been loaded.
> However, what are the technical reason why we need DynAPI to create a layer, 
> like the following:
> 
> 
> ...
> DynAPI.onLoad = function()
> {
>       myLayer = new DynLayer()
>       myLayer.setSize(100,100)
>       myLayer.setBgColor('#c0c0c0')
>       myLayer.moveTo(100,100)
>       DynAPI.document.addChild(myLayer)
> }
> ...
> 
> 
> 
> In short, why does the layer myLayer not appear if you write like this:
> 
> ...
> myLayer = new DynLayer()
> myLayer.setSize(100,100)
> myLayer.setBgColor('#c0c0c0')
> myLayer.moveTo(100,100)
> ...
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> 
> _______________________________________________
> Dynapi-Dev mailing list
> [EMAIL PROTECTED]
> http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://www.mail-archive.com/dynapi-dev@lists.sourceforge.net/

Reply via email to