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 thi开发者_StackOverflow中文版s possible using jquery ? any ideas plz
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.
$( '#flashswf' ).css( {
'width': $( window ).width() + 'px',
'height': $( window ).height() + 'px'
} );
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()
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);
精彩评论