Video Background resizing on browser window resize .

i wonder how the background video size is being changed in the below mentioned website on browser resize .

my current working demo is

this is a sample video which i am using as my background.

my current wok is in as2 , any clues even in as3 will be helpful ,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

That effect is actually quite simple, and is done in two parts.

First, they set the stage so that instead of automatically zooming to whatever size the window is, the "stage.scaleMode" is set, so that the contents won't automatically zoom, but will always stay the same size.

Here is some further reading on "Stage.scaleMode", and a quick Google search should return many more tutorials.

Second, they listen for if the stage resizes, update the position and size of all items on stage based on the new size of the stage. I have attached some sample code that you can place directly onto the timeline. When you change the size of the window, the video (named "my_video" in the example) should automatically resize to fit the entire stage.

Just ask if you have any questions regarding the code, or if you would like more information.

import flash.display.StageScaleMode;
import flash.display.StageAlign;

stage.scaleMode = StageScaleMode.NONE;
stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, onResize);

//Run the onResize function immediately

function onResize(ev:Event = null)
   my_video.height = stage.stageHeight;
   my_video.width = stage.stageWidth;

Open in new window

<i>Hm... I wonder where the edit button is...</i>

Anyway, the code I posted is for ActionScript 3, however, I'm sure there is a similar system in place for ActionScript 2. If you would like, I can search for an AS2 solution as well.

However, if possible, I would really recommend that you give AS3 a try. It is faster, more efficient, and has a lot more capabilities than AS2. If you need a few tutorials to get started, I can dig up a few links for you.

brainhaxAuthor Commented:
thanks IqAndreas , i will try to convert ur mentioned as3 to as2 for my project .. and will get back with problems or success story :)
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Hi Brainhax,

In continuance of your previous post ( here is an updated version of the document class. You'll need three aditional classes
(see attached) placed in the same folder as the I also attached a
flv for testing copy that to a folder named flv inside the build folder.
Hope you'll consider staying with AS3 ;)

Jakob E

package {
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.display.StageQuality;
    import flash.display.StageDisplayState;
    import flash.display.BitmapData;
   import VideoPlayer;    import MetadataEvent;    import VideoEvent;

    public class DocumentClass extends Sprite {
        private static const MIN_WIDTH:Number=760;
        private static const MIN_HEIGHT:Number=420;
        private var _video:VideoPlayer;
        private var _playlist:Array;
        private var _playlistIndex:int;
        private var _gridOverlay:Sprite;  
        private var _boxA:Sprite;// Top left  
        private var _boxB:Sprite;// Top right
        private var _boxC:Sprite;// Bottom left
        private var _boxD:Sprite;// Bottom right
        private var _boxE:Sprite;// Bottom center
        private var _aspectRatio:Number;// Variable holding the aspect ratio of your video
        // ==================================================================
        // Constructor
        // ==================================================================
        public function DocumentClass():void {
            // Stage set up

            // Video
            _video=new VideoPlayer();
            // Carate a looping playlist
            // Remove the above and outcomment lines below
            // _video.addEventListener(VideoEvent.STOPPED_STATE_ENTERED,playlistHandler,false,0,true)
            // _playlist=["../flv/GabelSt-option1.flv","../flv/Fisherman.flv","../flv/Corniche-Fireworks.flv"]
            // _playlistIndex=0;            
            // playlistHandler(null);
            // Set default aspect ratio 21/9
            // Video grid overlay
            _gridOverlay=new Sprite();
            // Boxes
            _boxA=new Sprite();
            _boxB=new Sprite();
            _boxC=new Sprite();
            _boxD=new Sprite();
            _boxE=new Sprite();

            // Assemble

            // Add resize eventlistener and call draw to handle the initial size

        // ==================================================================
        // Set movie aspect ratio and update layout by calling draw()
        // ==================================================================
        private function aspectRatioHandler(e:MetadataEvent):void{
        // ==================================================================
        // Playlist
        // ==================================================================
        private function playlistHandler(e:VideoEvent):void{
            var url=_playlist[_playlistIndex];

        // ==================================================================
         // Position and size display objects
        // ==================================================================
        private function draw(e:Event):void {
            var sw:Number=stage.stageWidth;
            var sh:Number=stage.stageHeight;

           // Scale video                        _video.width=Math.max(sw,MIN_WIDTH)            _video.scaleY=_video.scaleX/_aspectRatio            if(_video.height<sh){                _video.height=Math.max(sh,MIN_WIDTH/_aspectRatio);                _video.scaleX=_video.scaleX*_aspectRatio            }            // Round values to avoid odd pixel values            _video.width=Math.round(_video.width);            _video.height=Math.round(_video.height);            // Center position video            _video.x=Math.round(Math.max((sw-_video.width)/2,0));            _video.y=Math.round(Math.max((sh-_video.height)/2,0));

            // Position Boxes in relation to stage borders (or mimumum width/height)
            // Draw grid overlay
            var bmd:BitmapData=new BitmapData(2,2,true,0xff000000)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brainhaxAuthor Commented:
Jakob_E ! you r the best ,
your solution works like a charm , and i am happy liquid layouting instead of my demo
and getting interested in to as3 .

here is a part of the actual design , i hope that our decision for a liquid lay-outing will be best in this website case

thanks a lot for writing so much lines for me , i became a big fan of urs ,

Cheers .

brainhaxAuthor Commented:
simply awsome
Hi Raja,

I hope there is always a better solution - thats why I develop.
But at my point now this is how I would do it :)

The design looks good and I would sure like to see it live can I
ask you to post a link when you are done ?

If any questions you are always welcome  

Jakob E
brainhaxAuthor Commented:
yap sure i will post the link once its completed and live :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.