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...
♥0 |
Line 45 |
Modified 2010-12-06 18:40:40 |
MIT License
archived:2017-03-10 09:03:11
ActionScript3 source code
/**
* Copyright jozefchutka ( http://wonderfl.net/user/jozefchutka )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dzqE
*/
/*
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;
[SWF(width="465", height="465", frameRate="30", backgroundColor="#FFFFFF")]
public class WonderflApp extends Sprite
{
public function WonderflApp():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var tf:TextField = new TextField();
tf.width = stage.stageWidth;
tf.height = stage.stageHeight;
tf.text = "";
addChild(tf);
tf.appendText("1 inch = " + 1 * SystemScreen.INCH_TO_CENTIMETERS + " centimeters\n");
tf.appendText("1 inch = " + 1 * SystemScreen.INCH_TO_PIXELS + " pixels\n");
tf.appendText("1 cm = " + 1 * SystemScreen.CENTIMETER_TO_INCHES + " inches\n");
tf.appendText("1 cm = " + 1 * SystemScreen.CENTIMETER_TO_PIXELS + " pixels\n");
tf.appendText("100 pixels = " + 100 * SystemScreen.PIXEL_TO_INCHES + " inches\n");
tf.appendText("100 pixels = " + 100 * SystemScreen.PIXEL_TO_CENTIMETERS + " centimeters\n");
tf.appendText("your screen = " + SystemScreen.SCREEN_SIZE_IN_PIXELS * SystemScreen.PIXEL_TO_INCHES + " inches\n");
tf.appendText("your screen = " + 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()
{
}
}