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

video size/fullscreen example for stackoverflow

changing video dimensions according to stage.displayState
Get Adobe Flash player
by www0z0k 17 Nov 2010
    Embed
/**
 * Copyright www0z0k ( http://wonderfl.net/user/www0z0k )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xDC1
 */

package {
    import flash.events.Event;
    import flash.events.FullScreenEvent;
    import flash.media.Video;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    public class FlashTest extends Sprite {
        private var video:Video;
        private var bigVidWidth:int = 480;
        private var bigVidHeight:int = 360;
        private var smallVidWidth:int = 320;
        private var smallVidHeight:int = 240;
        public function FlashTest() {
            init();
        }
        private function init():void{
            graphics.beginFill(0xffff00);
            graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
            graphics.endFill();
            video = new Video();
            video.opaqueBackground = false;
            video.addEventListener(Event.ENTER_FRAME, updSize);
            stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullscreen);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress);
        }
        private function onFullscreen(e:FullScreenEvent):void{
            this.stage.focus = stage;
        }
        private function updSize(e:Event = null):void{
            video.width = stage.displayState == 'fullScreen' ? smallVidWidth : bigVidWidth;
            video.height = stage.displayState == 'fullScreen' ? smallVidHeight : bigVidHeight;
        }

        private function onKeyPress(e:KeyboardEvent):void {
            switch(e.keyCode) {
                case Keyboard.UP:
                if(numChildren == 0){
                    addChild(video);   
                }
                break;
                
                case Keyboard.DOWN:
                if(numChildren > 0){
                    removeChild(video);   
                }           
                break;  
                
                case Keyboard.LEFT:
                stage.displayState = stage.displayState == 'normal' ? 'fullScreen' : 'normal'; 
                break;               
            }    
        }
    }
}