FF: SystemScreen
forked from SystemScreen (diff: 15)
ActionScript3 source code
/**
* Copyright WLAD ( http://wonderfl.net/user/WLAD )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eCD7
*/
// forked from jozefchutka's SystemScreen
/*
more here:
http://blog.yoz.sk/2010/12/quick-tip-systemscreen-class/
Real device: SystemScreen:
24.0" 30.59"
3.4" 3.67"
please fill in comment your results...
*/
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.text.TextField;
import flash.text.TextFormat;
public class WonderflApp extends Sprite
{
public function WonderflApp():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
graphics.beginFill(0x0);
graphics.drawRect(0,0,0500,0500);
var tf:TextField = new TextField();
tf.width = stage.stageWidth;
tf.height = stage.stageHeight;
tf.defaultTextFormat = new TextFormat("Arial", 22, 0xFFFFFF, true );
tf.text = "";
addChild(tf);
tf.appendText("1 inch = \n" + 1 * SystemScreen.INCH_TO_CENTIMETERS + " centimeters\n");
tf.appendText("1 inch = \n" + 1 * SystemScreen.INCH_TO_PIXELS + " pixels\n");
tf.appendText("1 cm = \n" + 1 * SystemScreen.CENTIMETER_TO_INCHES + " inches\n");
tf.appendText("1 cm = \n" + 1 * SystemScreen.CENTIMETER_TO_PIXELS + " pixels\n");
tf.appendText("100 pixels = \n" + 100 * SystemScreen.PIXEL_TO_INCHES + " inches\n");
tf.appendText("100 pixels = \n" + 100 * SystemScreen.PIXEL_TO_CENTIMETERS + " centimeters\n");
tf.appendText("your screen = \n" + SystemScreen.SCREEN_SIZE_IN_PIXELS * SystemScreen.PIXEL_TO_INCHES + " inches\n");
tf.appendText("your screen = \n" + SystemScreen.SCREEN_SIZE_IN_PIXELS * SystemScreen.PIXEL_TO_CENTIMETERS + " centimeters\n");
}
}
}
import flash.system.Capabilities;
class SystemScreen
{
public static const INCH_TO_CENTIMETERS:Number = 2.54;
public static const INCH_TO_PIXELS:Number = Capabilities.screenDPI;
public static const CENTIMETER_TO_INCHES:Number = 0.393700787;
public static const CENTIMETER_TO_PIXELS:Number = Capabilities.screenDPI * 0.393700787;
public static const PIXEL_TO_INCHES:Number = 1 / Capabilities.screenDPI;
public static const PIXEL_TO_CENTIMETERS:Number = 2.54 / Capabilities.screenDPI;
public static const SCREEN_SIZE_IN_PIXELS:Number = Math.sqrt(
Capabilities.screenResolutionX * Capabilities.screenResolutionX +
Capabilities.screenResolutionY * Capabilities.screenResolutionY);
public function SystemScreen()
{
}
}