When talking about Silverlight and Flash, one should not miss out the browser integration part.
The sample below demonstrate three basic browser integration techniques: open popup, modify CSS and amend HTML content.
This is the first sample only. I will try to come up the 2th, 3th, 4th.. 10th samples later on.
Vote for this sample
Flash is Better? (110 votes)
Silverlight is Better! (155 votes)
Comparison
Flash implementation: 30 minutes (Implemented First)
Silverlight implementation: 40 minutes
What’s the difference?
- Browser Integration: navigateToURL [AS3] vs HtmlPage [C#]
Source codes
Browser Integration: navigateToURL [AS3] vs HtmlPage [C#]
I think you can do whatever you want in Flash. It’s because you can write JavasScript directly in AS3.
// AS3
// open popup
var js:String = "window.open('URL','_blank','height=300,width=300');";
var url : URLRequest = new URLRequest("javascript:" + js+ " void(0);");
navigateToURL(url, "_self");
// modify CSS
var js:String = "document.body.style.backgroundColor='#FF0000';";
// amend HTML content
var js:String = "document.getElementsByTagName('h1')[0].innerText = ‘Value’;”;
Silverlight provided a set of API to manage the HTML DOM. However, I am not sure if you can call your own JavaScript directly as in Flash.
// C#
// open Popup
HtmlPage.PopupWindow(new Uri("URL", UriKind.Absolute)
, "_blank",
new HtmlPopupWindowOptions() { Width = 300, Height = 300});
// modify CSS
HtmlDocument document = HtmlPage.Document;
document.Body.SetStyleAttribute("background", "#0080FF");
// amend HTML content
HtmlDocument document = HtmlPage.Document;
ScriptObjectCollection collections = document.GetElementsByTagName("h1");
HtmlElement htmlElement = (HtmlElement) collections[0];
htmlElement.SetProperty(”innerHtml”, “This is Silverlight Title”);