A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Actionscript 2 - Background Issue

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    14

    [F8] Actionscript 2 - Background Issue

    Hello everyone,

    I am using this code to tile a background image:

    Code:
    import flash.display.BitmapData;
    
    polaroid._x = Stage.width / 2;
    polaroid._y = Stage.height / 2;
    
    var tile:BitmapData = BitmapData.loadBitmap("tile");
    
    function fillBG() {
    	this.beginBitmapFill(tile);
    	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 stageL:Object = new Object();
    stageL.onResize = function() {
    	fillBG();
    	polaroid._x = Stage.width / 2;
    	polaroid._y = Stage.height / 2;
    }
    
    Stage.addListener(stageL);
    This works fine.. but what if I didn't want to tile the image but stretch it to fill the entire stage? Can anyone help please?

    Thanks in advance,

    Luke

  2. #2
    dust
    Join Date
    Dec 2004
    Location
    Australia
    Posts
    94
    I have the exact same question.... What's the actionscript for tiling a background image "endlessly"?

    So if the flash is published at 100% x 100%, the background image will continue to tile and fill the screen.

    Thanks.....
    [small] ok dust

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    14
    dustar...

    the code I originally posted does just that!! All you have to do is import an image to your library and export it for actionscript with the identifier "tile".

    What I am looking for is something different... I want the image to not be tiled but stretched accordingly to fill the entire browser

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    image._width = Stage.width;
    image._height = Stage.height;

    if you publish at 100% with margins at 0, the Stage will fill up the browser.

    More info on the Stage (listeners and onResize()) in the liveDocs (link in my footer)

    gparis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center