Study 1
- Desktop PC: 99.9 FPS (Firefox)
- MacBook Pro: 97 - 98 FPS (Safari)
- iPad (iOS 4.3): 19 - 20 FPS (updated 17/3 – 2011)
- HTC Desire HD (2.2): 15.5 - 16.5 FPS
- Inspire 4G (2.3): ~ 14 FPS (updated 17/3 – 2011)
- HTC Desire (2.2): 14.4 - 14.7 FPS
- iPad 1 (iOS 4.3): 13 – 13.5 FPS (updated 17/3 – 2011)
- iPad 1 (iOS 4.2): 12.4 - 13.3 FPS
- iPhone 4 (iOS 4.3): 9.9 - 10.5 FPS (updated 17/3 – 2011)
- iPhone 4 (iOS 4.2): 9.9 - 10.3 FPS
- iPhone 3GS (iOS 4.2): 9.9 - 10.3 FPS
- HTC Legend: 7.5 - 8.9 FPS
Conclusion 1
Desire HD is a bit higher. Not much, but still enough that it should be designated as a better settlement. Lowest is the HTC Legend, with around 8 fps.
Study 2
- Snow flakes was made as a separate class (Flake.as)
- Updated variables, etc so they are strictly typed
- Minor changes in variable names
- Used Flash Player’s flash.sensors.Accelerometer to handle motion
Flake.as
package
{
import flash.display.Sprite;
import flash.display.BitmapData;
public class Flake extends Sprite
{
private var canvasWidth;
private var canvasHeight;
private var speed: Number;
private var alpha: Number;
private var size: Number;
private var amp: Number;
private var shift: Number;
private var range: Number;
public function Flake (w, h, a, s)
{
this.canvasWidth = w;
this.canvasHeight = h;
this.x = 200;
this.y = Math.random () * -1 * h;
this.alfa = Math.random () * 0.5 + a;
this.speed = Math.random ();
this.size = s - this.speed - this.alfa;
this.amp = Math.random () * 2;
this.shift = Math.random () * 25 + 25;
if (Math.random ()> 0.5)
{
this.shift *= -1;
}
this.drift = Math.random () - 0.5;
draw ();
}
public function draw (canvas: BitmapData = null): void
{
this.graphics.beginFill (0xFFFFFF, this.alfa);
this.graphics.drawCircle (0.0, this.size);
this.graphics.endFill ();
}
public function move (f, wind): void
{
this.y + = this.speed;
this.x + = Math.cos (f / this.shift) * this.amp + + this.drift wind;
if (this.y> this.canvasHeight)
{
this.restart ();
}
}
public function restart (): void
{
this.y = -20;
this.shift = Math.random () * 25 + 25;
this.x = 200;
}
}
}
MainApp.as
package
{
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flashx.textLayout.elements.InlineGraphicElement;
import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;
import flash.text.TextField;
public class MainApp extends Sprite
{
private var bgflakes: Array = new Array ();
private var fgflakes: Array = new Array ();
private var bgFlakeCount: int = 200;
private var fgFlakeCount: int = 50;
private var frame count: int = 0;
private var wind: int = 0;
private var dWidth: int;
private var dHeight: int;
private var orientX: int = 1;
private var bgBitmapData: BitmapData;
private var bgCanvas: Bitmap;
private var fgBitmapData: BitmapData;
private var fgCanvas: Bitmap;
private var timer: Timer;
private var orientation: Boolean = false;
private var myAcc: Accelerometer;
private var filter Strength: int = 20;
private var frame hours: int = 0;
private var loading loop: Date = new Date ();
private var this loop: Date = new Date ();
private var fps: TextField;
public function MainApp ()
{
init ();
}
private function init ()
{
dWidth = this.stage.stageWidth;
dHeight = this.stage.stageHeight;
bgBitmapData = new BitmapData (dWidth, dHeight, false, 0x000000);
bgCanvas = new Bitmap (bgBitmapData);
fgBitmapData = new BitmapData (dWidth, dHeight, true, 0xFF0000);
fgCanvas = new Bitmap (fgBitmapData);
addChild (bgCanvas);
addChild (fgCanvas);
fps = new TextField ();
addChild (fps);
fps.textColor = 0xFFFFFF;
was i = 0;
for (i = 0; i {
bgflakes.push (New Flake (bgCanvas.width, bgCanvas.height, 0,3));
}
for (i = 0; i {
fgflakes.push (New Flake (fgCanvas.width, fgCanvas.height, 0.2,4));
}
hours = new Timer (10);
timer.addEventListener (TimerEvent.TIMER, draw);
timer.start ();
if (Accelerometer.isSupported)
{
orientation = true;
myAcc = new Accelerometer ();
myAcc.addEventListener (AccelerometerEvent.UPDATE, onAccUpdate);
}
}
private function onAccUpdate (e: AccelerometerEvent): void
{
orientX = e.accelerationX;
}
private function setWind ()
{
if (! orientation)
{
was mx: Number = mouseX - dWidth / 2;
wind = (mx / dWidth) * 3;
}
lodging
{
Wind = Number (orientX) * 3;
}
if (! wind)
{
wind = 0;
}
}
private function draw (e: Event hours)
{
frame count + = 1;
bgBitmapData.fillRect (new Rectangle (0.0, dWidth, dHeight), 0x000000);
fgBitmapData = new BitmapData (dWidth, dHeight, true, 0xFF0000);
setWind ();
was: int = 0;
for (i = 0; i {
bgflakes [i]. move (frame count, wind);
bgBitmapData.draw (bgflakes [i], new Matrix (1,0,0,1, bgflakes [i]. x, bgflakes [i]. y));
}
for (i = 0; i {
fgflakes [i]. move (frame count, wind);
fgBitmapData.draw (bgflakes [i]);
}
was this frame hours: int = (Number (this loop = new Date ())) - Number (last loop);
Frame hour + = (this frame - time frame hours) / filter strength;
load loop = this loop;
fps.text = (1000/frameTime). toFixed (1) + "fps";
}
}
}
Results 2
- Dersire HD (2.2): Canvas ~ 16.5 FPS and Flash 10.1 ~ 24.2 FPS
- Inspire 4G (2.3): Canvas ~ 14 FPS and Flash 10.1 ~ 22 FPS (updated 17/3 – 2011)
- HTC Desire (2.2): Canvas ~ 14.5 FPS and Flash 10.1 21.7 to 23.5 FPS
Conclusion
- How long the phone has been switched on.
- Is it connected to the charger.
- Programs running in the background.
- Video documentation of test
- http://eksempler.hjaelpmignu.dk/flash/actionscript/snowflake/snowcanvas.html (canvas)
- http://eksempler.hjaelpmignu.dk/flash/actionscript/snowflake/snowFLA.html (Flash)


