A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS3 - Bitmap screenshot of dragged image

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    27

    AS3 - Bitmap screenshot of dragged image

    Hi

    I have an masked image that is externally loaded onto my stage that the user can drag and position.

    I then need to be able to record or save where and how the user has positioned the image by either

    -taking a bitmap copy of where the user has positioned the image (my first and easiest thought of how to do this)

    -or is it possible to get X and Y co ordinates of where they have positioned it

    I have a movie currently set up but when the user clicks 'save and continue' it takes a copy of the original position of the image - not from where you have last dragged it to, any ideas?

    Full code and attached fla file below

    Many thanks for any help in advance

    Code:
    stop();
    
    //-------------- 
    // Loader
    //-------------- 
    var imageP1:Loader = new Loader();
    var request:URLRequest = new URLRequest('http://www.tiltworld.co.uk/TH785RFD/image.jpg');
    imageP1.load(request);
    addChild(imageP1);
    imageP1.x=100;
    imageP1.y=100;
    var image_Content:Sprite = new Sprite();
    var imageP1_Content:Sprite = new Sprite();
    image_Content.buttonMode=true;
    imageP1_Content.addChild(imageP1);
    image_Content.addChild(imageP1_Content);
    addChild(image_Content);
    //
    
    //--------------
    // Start Up Mask
    //--------------
    imageP1.mask=landscape_masks.landscape_mask_10x8;
    //
    
    //-------------- 
    // Drag
    //--------------
    
    imageP1.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    stage.addEventListener(MouseEvent.MOUSE_UP, drop);
    function drag(event:Event):void {
    	image_Content.startDrag();
    }
    function drop(event:Event):void {
    	image_Content.stopDrag();
    }
    //
    
    //--------------
    // Continue
    //--------------
    continue_btn.addEventListener(MouseEvent.MOUSE_DOWN, contin);
    function contin(event:Event):void {
    	bitmapCopy();
    }
    //
    
    //-------------- 
    // Bitmap Copy Function
    //--------------
    function bitmapCopy() {
    	var bd:BitmapData = new BitmapData(450, 400);
    	bd.draw(imageP1_Content);
    	var b:Bitmap = new Bitmap(bd);
    	addChild(b);
    	b.x=5;
    	b.y=480;
    }
    //
    Attached Files Attached Files

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    In the stopDrag() function use variables, which you declare before or getter/setter methods for the x and y position.
    - The right of the People to create Flash movies shall not be infringed. -

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