Pencake Ecard (Facebook Application) Flash vs Silverlight: Media / Video Player
Nov 24

It’s very common that you have to pass some predefined parameters to Flash / Silverlight in different pages of the website. 

How can we achieve that? Here is a simple example.

(Please note that I have disabled the comment temporarily. It’s because there are many spam messages recently. I will fix that as soon as possible)

Comparison

Flash implementation: 20 minutes
Silverlight implementation: 40 minutes  (Implemented First)
What’s the difference?

  • LoaderInfo.parameters [AS3] vs InitParams[C#]

Source codes

Flash

Silverlight

LoaderInfo.parameters [AS3] vs InitParams[C#]

In AS3, you can get either pass the parameters using URL  or through JavaScript. Here is an example for URL method:

<object width=”550″ height=”400″ id=”PassingQueryString”>

<param name=”movie” value=”PassingQueryString.swf?param1=value&param2=value”/>

<embed src=”PassingQueryString.swf?param1=value&param2=value”/>

</object>

// AS3
// get all the parameters values
for (var key:String in loaderInfo.parameters){
	var value:String = loaderInfo.parameters[key];
}

For Silverlight, you have to specific a “InitParams” parameter inside the object tag of the HTML Source.  For example:

<object type=”application/x-silverlight-2″ width=”100%” height=”100%”>

<param name=”source” value=”PassingQueryString.xap”/>

<param name=”InitParams” value=”param1=value,param2=value2″/>

</object>

// C#
// get the params via the Application Class
private void Application_Startup(object sender, StartupEventArgs e)
{
	IDictionary parameters = e.InitParams;
	foreach (string key in parameters.Keys)
	{
		string value = parameters[key];
	}
        this.RootVisual = new Page();
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

6 Responses to “Silverlight vs Flash: Passing Query String / Parameters”

  1. iongion Says:

    How the hell is Silverlight better ?
    Because of strong type and weird syntax ?
    Not only that, in flash you can access those parameters at any moment, not only at application_startup (that would involve making additional code to have them available at any given time).

    Most flash designers don’t have a clue about strong typing and they prefer untyped approaches cause they feel it is natural.

    Now again, how in hell is Silverlight better ? I guess the ones that vote here are either MS fanboys, either they don’t pay enough attention.

  2. Bigsby Says:

    Strong typing isn’t mandatory. It’s an option that most find quite appealing because, for instance, it provides consistency in coding and thus faster processing.

    I sure would like to know what you mean “weird syntax”. The main advantage of Silverlight is precisely the fact that it’s syntax is the same as rest of the very worldwidely used .Net.

  3. Matthew Foos Says:

    How would Flash people even understand the power of Silverlight… It’s like explaining to people in the 1400’s that the world isn’t flat…. [Condescendingly] You are right Flash guys…. Flash is better, but I’d get your resumes ready fast…

  4. Ian Patrick Hughes Says:

    “weird syntax”?

    What is so weird with an open curly - close curly language? Flash lacked any sort of real OOP capabilities until after several iterations. Now that flash has finally become a first class programmatic platform instead of a design one with programming features shoe-horned in; it has a competitor.

    The only sad news for flash is, that competitor knows programmers really well and designed a system that produces great effects without the daunting design platform. I love to work in photoshop, but Flash was never a pleasure until the Adobe buy out.

    The good news for flash is, the silverlight community is going through all of the pains flash did leading up to version 5. When should it be used and how much? What is done in poor design? Etc.

  5. Tim Robles Says:

    An alternative way to grab query parameters assuming it’s embedded within a page is to simply iterate through the IDictionary of HtmlPage.Document.QueryString. Accessible from anywhere. In flash, loaderInfo.parameters aren’t accessible from anywhere, unless you have a reference to the stage or saved those values.

  6. Lucy Drossman Says:

    hi!, thanks for the info, this post was really utile ! avafx forex broker

Leave a Reply