Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: Problems with beginBitmapFill

  1. #1

    Problems with beginBitmapFill

    Hi everyone,

    I've been having some problems with "beginBitmapFill"; I simply want to use it to draw a single, un-tiled image at a certain point on the screen, like so:

    Code:
        graphics.beginBitmapFill(bitmap, null, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    The problem is that if you set the "tile" value in beginBitmapFill to false, then it will only draw the image once, at (0, 0). Is there anyway to offset the drawing of the image to a specific point (in my case (100, 100))? Thanks for reading, hope it's not too much of a lame question!

    Cheers,

    Mike.

  2. #2
    No worries its confusing for sure... Esp the "Matrix" class... Luckily we have a few cool shortcut functions that make it easier for us... In this case you want to use translate. The Matrix class basically allows us to transform the bitmap before pasting it where we want it... Try this then make the changes as necessary to suit your needs.

    Code:
        import flash.geom.*;
        var _mtx:Matrix = new Matrix()
        _mtx.translate(_xmouse,_ymouse);
        graphics.beginBitmapFill(bitmap, _mtx, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    Quote Originally Posted by megadev View Post
    Hi everyone,

    I've been having some problems with "beginBitmapFill"; I simply want to use it to draw a single, un-tiled image at a certain point on the screen, like so:

    Code:
        graphics.beginBitmapFill(bitmap, null, false, false);
        graphics.drawRect(100, 100, test_image.width, test_image.height);
        graphics.endFill();
    The problem is that if you set the "tile" value in beginBitmapFill to false, then it will only draw the image once, at (0, 0). Is there anyway to offset the drawing of the image to a specific point (in my case (100, 100))? Thanks for reading, hope it's not too much of a lame question!

    Cheers,

    Mike.

  3. #3
    Thanks shanimal, that's sorted it now. I come from a J2ME / C++ background, so I often feel like I'm trying to get round Flash's "features". ;-) In this case I just wanted to draw a sprite at an x, y screen co-ordinate without having to setup a new sprite and use addChild, as you probably should do. However, do you think that drawing sprites using a transformed matrix and beginBitmapFill is particularly slow? Is it frowned upon amongst Flash programmers? Anyway, thanks for your help - this technique will come in very handy. :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012