From: Chris H. <chr...@ea...> - 2004-01-15 02:44:32
|
Hi there- I am trying to implement the DynAPI to create layers on the fly generating javascript from PHP which loops and creates the layers. However, these layers created on the fly do not respond to the functions included in the API. For example, in the code below I can move 'testLayer' but I cannot get layer a[1] to move. I also tried changing the name of the layer to a concatenated all text name (ex: myLayer1, myLayer2) but the layers are still causing a DynAPI error. Please help! Here is the compiled code I am using: <html> <head> <title>DynAPI Distribution: Create Example</title> <script language="Javascript" src="src/dynapi.js"></script> <script language="Javascript"> DynAPI.setLibraryPath('src/lib/'); DynAPI.include('dynapi.api.*'); </script> <script language="Javascript"> var divContent=[]; divContent[0] = "null"; divContent[1] ="<a href=\"#\" onclick=\"hideShow(2);\"<img src=\"images/arrow_up.gif\">Bay</a>"; divContent[2] ="<a href=\"#\" onclick=\"swapIt('theTarget','images/bay/images/bay03.jpg');\" border=0><img src=\"images/bay/thumbs/tn_bay03.jpg\" hspace=2 vspace=2></a>; divContent[3] ="<a href=\"#\" onclick=\"hideShow(4);\"<img src=\"images/arrow_up.gif\">Birthday</a>"; divContent[4] ="<a href=\"#\" onclick=\"swapIt('theTarget','images/birthday/images/birthday03.jpg');\" border=0><img src=\"images/birthday/thumbs/tn_birthday03.jpg\" hspace=2 vspace=2></a>; divContent[5] ="<a href=\"#\" onclick=\"hideShow(6);\"<img src=\"images/arrow_up.gif\">Friends</a>"; divContent[6] ="<a href=\"#\" onclick=\"swapIt('theTarget','images/friends/images/friends03.jpg');\" border=0><img src=\"images/friends/thumbs/tn_friends03.jpg\" hspace=2 vspace=2></a>; DynAPI.onLoad = function() { var a=[]; var divCount=0; for (var i=1;i<6;i=i+2){ a[i] = new DynLayer(); DynAPI.document.addChild(a[i]); a[i].setSize(400,20); a[i].setBgColor('orange'); a[i].setX(30); a[i].setY((50+25*divCount)); a[i].setHTML(divContent[i]); a[i+1] = new DynLayer(); DynAPI.document.addChild(a[i+1]); a[i+1].setSize(400,20); a[i+1].setBgColor('yellow'); a[i+1].setX(30); a[i+1].setY((75+25*divCount)); a[i+1].setVisible(false); a[i+1].setHTML(divContent[(i+1)]); divCount++; } testLayer = new DynLayer(); DynAPI.document.addChild(testLayer); testLayer.setSize(50,50); testLayer.setBgColor('yellow'); testLayer.setX(400); testLayer.setY(400); } function hideShow(thisDiv) { testLayer.moveBy(0,50); //} } </script> </head> <body bgcolor="#ffffff"> ... </body> </html> |