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
Resilience Rectangle [Flash 9, AS3] (8.6 KiB, 1,303 hits)
Resilience Rectangle [Silverlight 2, C#] (19.1 KiB, 2,041 hits)
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) {}

September 27th, 2008 at 10:51 am
you can drag the red dot outside of the flash window, but you cannot do that in silverlight
September 27th, 2008 at 12:03 pm
thanks! great examples.
how to achieve this effect
http://shiverlight.net/Demos_v2/MouseGesture/
September 27th, 2008 at 12:06 pm
to see the effect click and drag mouse
September 27th, 2008 at 1:19 pm
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.
September 27th, 2008 at 5:02 pm
Thanks for sharing this.How to achieve this nice resilience effect?
Regards,
image clipping services
September 29th, 2008 at 10:54 pm
[...] Silverlight vs Flash: Resilience Rectangle [...]
October 3rd, 2008 at 11:29 pm
To make the dot drag outside the silverlight window you need to use capturemouse when you click.
April 11th, 2009 at 5:05 am
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.
September 28th, 2009 at 6:21 am
[...] 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 [...]