Silverlight vs Flash: Stray Sheep Flash vs Silverlight: Simple Text Effect
Sep 27

You may try to drag and drop the red dots around the rectangle. It will produce a very nice resilience effect!

Comparison

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

  • Coding Style [AS3] vs [C#]

Source codes

Flash

Silverlight

Coding Style[AS3] vs [C#]

Having a standard coding style is really a headache for many programmers. For me, after working with AS3 for nearly 2 years, I have already developed my own coding style. Just a little sharing and hope can give you some references.

// AS3
// public variable,
public var variableName:Number = 10;

// private variable
private var _variableName:Number = 10;

// static variable
public var VARIABLE_NAME:Numebr = 10;

// getter, always public
public function get variableName():Number{
	return _variableName;
}

// setter, always public
public function set variableNamue(value:Number):void{
	_variableName = value;
}

// public function
public function functionName():void{ }

// private function
private function functionName():void{}

// event listener
addEventListener(MouseEvent.MOUSE_MOVE, on_mouse_move);
private function on_mouse_move(e:MouseEvent):void {}

OK, let’s see what are the differences in C#.

// C#
// public variable (capitalized on the first letter)
public double VariableName = 10;

// private variable
private double _variableName = 10;

// static variable
public double VARIABLE_NAME = 10;

// getter and setter
public double VariableName{
	get { return _variableName; }

	set{ _variableName = value; }
}

// public function (capitalized on the first letter)
public void FunctionName(){ }

// private function
private void functionName(){}

// event listener (I just use the generated code)
MouseMove += new MouseEventHandler(className_MouseMove);
void className_MouseMove(object sender, MouseEventArgs e) {}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

9 Responses to “Silverlight vs Flash: Resilience Rectangle”

  1. unruledboy Says:

    you can drag the red dot outside of the flash window, but you cannot do that in silverlight

  2. vladimir Says:

    thanks! great examples.

    how to achieve this effect
    http://shiverlight.net/Demos_v2/MouseGesture/

  3. vladimir Says:

    to see the effect click and drag mouse

  4. admin Says:

    unruledboy, yes, I am still figuring how to manage those mouse events.

    vladmir, that’s great. I am trying to post more about mouse effect application as well.

  5. SBL-Photoshop Masking Says:

    Thanks for sharing this.How to achieve this nice resilience effect?

    Regards,
    image clipping services

  6. Silverlight Cream for September 26, 2008 - 2 -- #379 Says:

    [...] Silverlight vs Flash: Resilience Rectangle [...]

  7. Tony Says:

    To make the dot drag outside the silverlight window you need to use capturemouse when you click.

  8. Silverlight user Says:

    Another comparison by someone who obviously loves flash, you let the flash version update freely while you restrict the Silverlight version to 24 FPS, making it look as if it was performing badly, while you’re really doing it on purpose, in reality, the SL version is perfectly smooth.

    Add this line to the beginning of the timer tick:
    DateTime start = DateTime.Now;
    Add this line to the end of the timer tick:
    _timer.Interval = new TimeSpan(0, 0, 0, 0, ((int)(start - DateTime.Now).TotalMilliseconds));

    …and you’ll see how it really performs: perfectly.

    There are better ways of counting the real ticktime, this is just something that comes in mind with 5 seconds of thinking and for the purpose of showing intentional ’sabotage’ on the SL versions code, it does the job.

    Also, as Tony already stated, both
    this.CaptureMouse(); from ellipse_MouseLeftButtonDown
    and
    this.ReleaseMouseCapture(); from ellipse_MouseLeftButtonUp
    are missing as well, making the animation stop once mouse leaves the window.

  9. Resilience Rectangle | Silverlike - A Free Microsoft Silverlight 3 Directory Says:

    [...] drag and drop related application created by Terence Tsang. Try to drag and drop the red dots around the rectangle. It will produce a very nice resilience [...]

Leave a Reply