In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

screen resolution

multipart project 3
part 1 of, I don't know, like 5

Background:
Javascript has a pretty easy way of finding out the user's screen resolution. Can Flash do it too?

Task:
- look up how to get the screen resolution
- display it...
Get Adobe Flash player
by wh0 18 Oct 2010
/**
 * Copyright wh0 ( http://wonderfl.net/user/wh0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/a30J
 */

package {
    import flash.text.TextField;
    import flash.system.Capabilities;
    import flash.display.Shape;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public function FlashTest() {
            var w:Number = Capabilities.screenResolutionX;
            var h:Number = Capabilities.screenResolutionY;
            var scale:Number = 500. / 2560.;
            
            var l:Loader = new Loader();
            l.load(new URLRequest('http://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Vector_Video_Standards2.svg/500px-Vector_Video_Standards2.svg.png'));
            addChild(l);
            
            var s:Shape = new Shape();
            s.graphics.beginFill(0x000000, 0.25);
            s.graphics.drawRect(w, 0, 2560 - w, 2048);
            s.graphics.drawRect(0, h, w, 2048 - h);
            s.scaleX = scale;
            s.scaleY = scale;
            addChild(s);
            
            var t2:TextField = new TextField();
            t2.text = loaderInfo.parameters['viewer.displayName'];
            t2.scaleX = 2;
            t2.scaleY = 2;
            t2.alpha = 0.5;
            t2.x = 0;
            t2.y = h * scale - 32;
            addChild(t2);
            
            var t:TextField = new TextField();
            t.text = w + 'x' + h;
            t.scaleX = 4;
            t.scaleY = 4;
            t.textColor = 0xffffff;
            t.x = -12;
            t.y = h * scale - 12;
            addChild(t);
        }
        
    }
}