all groups > flash actionscript > may 2007 >
You're in the

flash actionscript

group:

stretching image to size of browser using BitmapData class and dawing api


stretching image to size of browser using BitmapData class and dawing api eljefeloco101
5/17/2007 11:44:07 PM
flash actionscript:
Ive been working from a great tutorial found at
http://www.gotoandlearn.com/download.php on creating full browser flash. It
uses the BitmapData class and drawing api to attach an image to the stage and
have the image tile when the browser window is resized. The problem is that I
want my image to stretch to fit the browser window instead of tile.

I've looked into alternatives on attaching my image to a movieclip and having
the mc resize, but thats no good since I'm using the drawing api to draw other
elements on the background. The movieclip then covers those other elements.

Any ideas?

import flash.display.BitmapData;

var bgImage:BitmapData = BitmapData.loadBitmap("bgImage");

function fillBG() {
this.beginBitmapFill(bgImage);
this.moveTo (0,0);
this.lineTo (Stage.width,0);
this.lineTo (Stage.width, Stage.height);
this.lineTo (0, Stage.height);
this.lineTo (0,0);
this.endFill ();

}

fillBG();

var stageListen:Object = new Object();
stageListen.onResize = function() {
fillBG();
}

Stage.addListener(stageListen);

import flash.display.BitmapData;

var bgImage:BitmapData = BitmapData.loadBitmap("bgImage");

function fillBG() {
this.beginBitmapFill(bgImage);
this.moveTo (0,0);
this.lineTo (Stage.width,0);
this.lineTo (Stage.width, Stage.height);
this.lineTo (0, Stage.height);
this.lineTo (0,0);
this.endFill ();

}

fillBG();

var stageListen:Object = new Object();
stageListen.onResize = function() {
fillBG();
}

Stage.addListener(stageListen);
Re: stretching image to size of browser using BitmapData class and dawing api kglad
5/18/2007 1:57:04 AM
Re: stretching image to size of browser using BitmapData class and dawing api eljefeloco101
5/18/2007 4:16:05 AM
Just the background image and some semi-transparent overlays on top of the image (which I'm using the drawing api to draw as well).

thanks for looking.
AddThis Social Bookmark Button