A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] negative x / y areas with copypixels

  1. #1
    Member
    Join Date
    Jun 2000
    Posts
    54

    resolved [RESOLVED] negative x / y areas with copypixels

    Hi,

    this is quite tricky to explain, so apologies if it's a bit confusing...

    I have a movieclip which contains graphics within negative x and y areas. I'm trying to duplicate some of the graphics within this negative space using copyPixels. I've tried all variety of negative values in my code but all negative areas remain uncopied within the duplicated bitmap.

    Can anyone advise please? Is it even possible? Thank you. Jon ...

    PHP Code:
    var bitmapData1:BitmapData = new BitmapData(700600false0xCC0000);// width height
    var bitmapData2 :BitmapData = new BitmapData(350600false0xCCCC00);// width height

    function enterFrameFunc(e:Event) {
        
    bitmapData1.draw(allIntro);
        var 
    rect1:Rectangle = new Rectangle(350, -100350600);
        
    bitmapData2.copyPixels(bitmapData1rect1, new Point(0,100));

    }

    allIntro.addEventListener(Event.ENTER_FRAME,enterFrameFunc);

    var 
    bm2:Bitmap=new Bitmap(bitmapData2);
    this.addChild(bm2); 

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I think the problem is not the copypixels, but the original draw. You might have to offset the draw with a matrix argument so that the entirety of allIntro will be at positive coordinates.

  3. #3
    Member
    Join Date
    Jun 2000
    Posts
    54
    Thanks for taking time to reply 5TonsOfFlax,

    do you mean something like:
    PHP Code:
    bitmapData1.draw(allIntronullnullnull, new Rectangle(350, -100350600)); 
    ?

    because that didn't work either. If you mean something else, could you please elaborate?

    Many thanks

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    That would be the clipRect, which I have never satisfactorily gotten to do anything useful.

    The second parameter to draw is a Matrix which can define a rotation, translation, scale or skew to transform the source by. You need a translation.
    Code:
    var transMat:Matrix = new Matrix();
    transMat.translate(100, 0); //move right by 100.  Might be backwards.
    bitmapData1.draw(allIntro, transMat);
    Another alternative would be to place allIntro into a container sprite such that allIntro is entirely in positive coordinates of the container, then draw the container instead of allIntro.

  5. #5
    Member
    Join Date
    Jun 2000
    Posts
    54
    Nice one!
    The matrix / translate solution works a treat

    Thanks very much.
    Last edited by jon ps; 04-25-2008 at 11:08 AM.

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