views:

653

answers:

4

Hi Folks

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

+1  A: 

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()

rahul
+1  A: 
$( '#flashswf' ).css( { 
     'width': $( window ).width() + 'px', 
     'height': $( window ).height() + 'px'
} );
Jacob Relkin
+1  A: 

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);
Heath Hunnicutt
this is unrelated answer .. i am asking jquery and javascript not flash action scripts .. thanks anyway
NetCaster
Are you sure the problem is your div doesn't resize correctly, or maybe it does but the flash control does not fill it afterward?
Heath Hunnicutt
+1  A: 

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.

Skrim
yes exactly i need to maintain the swf state and this is my real problem can you explain this more plz .. thank you
NetCaster
Make a table that fills the browser window and put the Flash app with width and height of 100% into center cell. Then using the non-center cells, "push" the Flash content into desired position and size. To switch to fullscreen, change the width and height of the other cells to zero - this causes the center cell with Flash content to stretch to full window size. You probably need to do a lot of tweaking to achieve good browser compatibility.
Skrim