简体   繁体   中英

resize flash div to full browser height and width?

i have a page with swf flash flash with width 300x250

<div id="flashswf"> ...some flash </div>
<div id="maxme">full screen</div>

i have a link called full screen and i need to maximize the flashswf div to fit the current browser maximum height and width

is this possible using jquery ? any ideas plz

Use

$(window).width();

and

$(window).height();

to get the window width and height

$(function() {
    $("#maxme").click ( function() {
        $("#flashswf").width($(window).width());
        $("#flashswf").height($(window).height());
    });
});

See width() and height()

$( '#flashswf' ).css( { 
     'width': $( window ).width() + 'px', 
     'height': $( window ).height() + 'px'
} );

I believe part of what you need is to set the stage.scaleMode = StageScaleMode.NO_SCALE . Otherwise Flash attempts to maintain the settings from the SWF file. See the documentation for more info.

I grabbed this example code from Adobe :

import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;

var swfStage:Stage = videoScreen.stage;
swfStage.scaleMode = StageScaleMode.NO_SCALE;
swfStage.align = StageAlign.TOP_LEFT;

function resizeDisplay(event:Event):void
{
    var swfWidth:int = swfStage.stageWidth;
    var swfHeight:int = swfStage.stageHeight;

    // Resize the video window.
    var newVideoHeight:Number = swfHeight - controlBar.height;
    videoScreen.height = newVideoHeight;
    videoScreen.scaleX = videoScreen.scaleY;

    // Reposition the control bar.
    controlBar.y = newVideoHeight;
}

swfStage.addEventListener(Event.RESIZE, resizeDisplay);

It's possible, but note that browser resets the Flash application if the style of the element containing it (or any parent element) is changed.

If you need to maintain the state of the application, you can, for example, put it in the middle of a 3x3 table with 100% width and height, and then manipulate styles of all other cells.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM