dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Loading a JPeg from File into BitmapData.loadBitmap()?

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Posts
    227

    [F8] Loading a JPeg from File into BitmapData.loadBitmap()?

    Simply put, how can it be done?

    I am trying to dynamically load a .jpg file and use it as a background tile. So that means i need to fill the background with that.

    Now the only way i know how to do this is with the bitmapdata but that seems to only work for images in the library.. the help file also says "library" and makes no mention of it loading external images. So how can this be done?

    Here is the code i use for the image that is on the stage, just for reference.
    Code:
    import flash.display.BitmapData;
    var pattern:BitmapData = BitmapData.loadBitmap("bgTile");
    function createTiles():Void {
    	with (_level0) {
    		beginBitmapFill(pattern);
    		moveTo(0, 0);
    		lineTo(Stage.width, 0);
    		lineTo(Stage.width, Stage.height);
    		lineTo(0, Stage.height);
    		lineTo(0, 0);
    		endFill();
    	}
    }

  2. #2
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Look into the cacheAsBitmap() function

    link

  3. #3
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    For external files, use loadMovie to load the jpg into a movieclip, then draw the contents of the clip into a BitmapData object using BitmapData.draw();

    K.

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