From: Humberto G. <gon...@ma...> - 2006-01-19 19:48:23
|
<BODY><P>Here are the steps I used to create a widget:</P> <P><STRONG>Step1:</STRONG> Create a folder (<STRONG>../src/mywidgets</STRONG>) for the widgets</P> <P><STRONG>Step 2:</STRONG> Create a widget and save it as <STRONG>../src/mywidgets/myfirstwidget.js</STRONG></P> <P><FONT style="BACKGROUND-COLOR: palegoldenrod">function MyFirstWidget(text) {<BR> this.DynLayer = DynLayer;<BR> this.DynLayer(text);<BR> alert(text);<BR>}<BR></FONT><FONT style="BACKGROUND-COLOR: palegoldenrod">var p = dynapi.setPrototype('DynLayer','MyFirstWidget');</FONT></P> <P><STRONG>Step3:</STRONG> Add the codes below to the <STRONG>../src/ext/packages.js</STRONG> file</P><PRE><FONT style="BACKGROUND-COLOR: palegoldenrod">var p = dynapi.libary.path;<BR>dynapi.library.addPackage('dynapi.mywidgets',p);<BR>dynapi.library.add('dynapi.mywidgets.MyFirstWidget','myfirstwidget.js','DynLayer');<BR></FONT></PRE><PRE><STRONG>Step 4:</STRONG> Create an HTML document and save it to the <STRONG>examples</STRONG> folder</PRE><PRE><FONT style="BACKGROUND-COLOR: palegoldenrod"><html><BR><head><title>My First Widget</title><BR><script language="Javascript" src="../src/dynapi.js"></script><BR><script language="Javascript"><BR> dynapi.library.setPath('../src/');<BR> dynapi.include('dynapi.api');<BR> dynapi.include('dynapi.mywidgets.MyFirstWidget');<BR></script><BR><script language="Javascript"><BR><BR>dynapi.document.addChild(new MyFirstWidget('Ok');<BR></script><BR> </head><BR><body><BR></body><BR></html></FONT></PRE><PRE><FONT style="BACKGROUND-COLOR: white">However, the following error occurs: <FONT color=red>dynapi.document is null or not an object</FONT></FONT></PRE></BODY> |