PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
copy pixels
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: copy pixels

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    996

    copy pixels

    This is driving me mad. All I want to do is copy pixels or clone pixels from one Sprite into another empty sprite. I can get it to do it but it brings the data in as a square. I basically have a Sprite with a circle bitmap inside it. well its a png so its got transparency.

    Below half works. But its also so much code to just get a copy of one sprite to another.

    Actionscript Code:
    var bmd:BitmapData = new BitmapData(button.model.width, button.model.height);
                bmd.draw( button );
                var newBmd:BitmapData = new BitmapData( bmd.width, bmd.height);
                newBmd.copyPixels(bmd, bmd.rect, new Point(0,0), null,null,true );
                var bitmap:Bitmap = new Bitmap( newBmd );

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Do you really need a separate bitmap data? If you don't, then you can just use bmd to back your bitmap. No nead to create newBmd.

    Also, since you appear to be copying everything, even if you do need a separate bitmapdata, you could use the clone method.

    And finally, I'm not seeing a second Sprite, assuming that button is the first Sprite.

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    996
    Yea I might not need a second bitmapData.
    YEs button is the Sprite with my png inside it.
    What that how can I create a clone of this that still holds its transparency.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    As it stands, it looks like that should preserve the transparency. But you won't have a Sprite at the end, you'll have a Bitmap.

    If your button is in your library, then you could export it for actionscript, give it a class name, then just create a new instance of it.
    Code:
    var button2:MyButton = new MyButton();
    That will create another instance of it as it exists in the library.

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