Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

How to scale the Stage to fit the screen?

$
0
0

Currtent code dosen't work very well. Any better solution? Thanks,


var videoHDWidth:Number = 1024;

var videoHDHeight:Number = 768;

var videoRegWidth:Number = 550;

var videoRegHeight:Number = 400;

// 3. Create an event handler to toggle full screen

// mode when a button is clicked.

function toggleFullScreen(event:MouseEvent):void {

 

    // Jump to full screen

    if( stage.displayState == StageDisplayState.NORMAL ) {

        // Set video to 100% size

        flvControl.setSize(videoHDWidth, videoHDHeight);

        // Position button

        // Activate hardware scaling based on HD state...

        stage.fullScreenSourceRect = new Rectangle(0, 0, videoHDWidth, videoHDHeight);

        stage.displayState = StageDisplayState.FULL_SCREEN;

    }

    // Return to normal size

    else{

        // Set video to regular size

        flvControl.setSize(videoRegWidth, videoRegHeight);

        // Position button

        // Return to normal mode

        stage.displayState = StageDisplayState.NORMAL;

    }

}

 

//fullscreen_btn.addEventListener(MouseEvent.CLICK, toggleFullScreen);

 

// 4. Resume normal mode if the Escape button is pressed during full screen

function resumeNormalMode(event:FullScreenEvent):void

{

    // The displayState is already 'normal' by the time this

    // event fires. This signals that the Escape button was clicked.

 

    if (stage.displayState == StageDisplayState.NORMAL)

    {

        // Set video to regular size

        flvControl.setSize(videoRegWidth, videoRegHeight);

        // Position button ;

        // Return to normal mode

        stage.displayState = StageDisplayState.NORMAL;

    }

}

stage.addEventListener(FullScreenEvent.FULL_SCREEN, resumeNormalMode);

 

// 5. Set video parametes

flvControl.align = VideoAlign.CENTER;

flvControl.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO;

flvControl.fullScreenTakeOver = false;


Viewing all articles
Browse latest Browse all 13519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>