So lets take a closer look at that class I posted earlier. So if you actually want to use it to see it working I thought it might be nice to fill in the rest. See the attached zip but basically we have 5 files. The first one is our web page or 'Default.html'; In here we see a script reference to our 3 javascript files. and then there is a script block that calls a function createSilverlight and then there are three parameters. The createSilverlight function is found HelloWorld.xaml. This is what basically creates a reference to our Silverlight application class and gets everything rolling. If you open this script file you can see the function definition and then where it creates the variable 'scene' you see that it is set to a new instance of our hello world class.
Back to the default.html page. So of the 3 references to JavaScript files we have the Silverlight.js which is the library used for creating our silverlight controls. (look for a new better version on our blog here shortly as after reviewing it... it needs some work) anyway the next file is the HelloWorld.ext.js script which is what holds our createSilverLight function we talked about. Then is our HelloWorld.xaml.js. This is the script block that contains our HelloWorldClass (see earlier post or the attachment here).
Lets look at our call to 'createSilverlight' call again. You note the version parameter is a reference to our xaml which is how it gets pulled in. Looking actually at the xaml it is straight forward enough, basically a canvas in a canvas with a canvas with some rectangles for a nice vancy background and a textblock with nothing in it. Our constructor on our HelloWorld class sets the text to its message property and thus we get our hello world.
One last thing to point out is this method of declaring the class gets around the issue with using Silverlight in the context of an object tag. When you use the object tag then you end up having to 'click' the control first before it works complete. Using this dynamic script method using the Silverlight.js we can get around that issue and our stuff just works if a bit more cryptic. Oh and one more thing is that we also then get access to the browser object model which is not the case if we wrap everything in an object tag and have the xaml pull in our script. Oh and this uses the Beta Silverlight version 1.0