www.webdeveloper.com
Results 1 to 1 of 1

Thread: AS3 - Bitmap Clone of masked area of loaded image

Threaded View

  1. #1
    Join Date
    Dec 2009
    Posts
    23

    AS3 - Bitmap Clone of masked area of loaded image

    Hi

    Once again i have hit a brick wall and am in need of some help!

    I have a 2 frame flash file

    - frame 1 the user has an externally loaded image on stage - where they can turn it into different shapes (using masks) and also drag it around...

    -frame 2 a bitmap copy of the users selection/dragging gets taken and saved on the stage

    On frame 2 i have the bitmap clone code in...:

    Code:
    var imageA1:Bitmap;
    imageA1=new Bitmap(Bitmap(imageP1.content).bitmapData.clone());
    ...but i cannot target the correct object/movieclip/sprite for it to work (currently set at imageP1.content which just gives me the whole image) I basically need to target either a specific area of the stage or target the image within the mask 'landscape_masks.landscape_mask_10x8.landscape_mask_10x8_main;'


    The full code can be seen below and i have attached the fla file

    Please, please help??

    Many thanks in advance

    John

    FRAME 1:
    Code:
    stop();
    
    //------------------------------------------------------------------------------------------------ 
    // Loader
    //------------------------------------------------------------------------------------------------ 
    
    var imageP1:Loader = new Loader();
    var request:URLRequest = new URLRequest('http://www.tiltworld.co.uk/TH785RFD/image2.jpg');
    imageP1.load(request);
    addChild(imageP1);
    
    imageP1.x=200;
    imageP1.y=200;
    
    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();
    }
    //
    
    //------------------------------------------------------------------------------------------------ 
    // Buttons
    //------------------------------------------------------------------------------------------------ 
    
    stadium_btn.addEventListener(MouseEvent.MOUSE_DOWN, stadiumView);
    pitch_btn.addEventListener(MouseEvent.MOUSE_DOWN, pitchView);
    seats_btn.addEventListener(MouseEvent.MOUSE_DOWN, seatView);
    
    function stadiumView(event:Event):void {
    	imageP1.mask=landscape_masks.landscape_mask_10x8;
    }
    
    function pitchView(event:Event):void {
    	imageP1.mask=landscape_masks.landscape_mask_10x8.landscape_mask_10x8_main;
    }
    
    function seatView(event:Event):void {
    	imageP1.mask=landscape_masks.landscape_mask_10x8.landscape_mask_10x8_sides;
    }
    //
    
    //------------------------------------------------------------------------------------------------ 
    // Continue
    //------------------------------------------------------------------------------------------------ 
    
    continue_btn.addEventListener(MouseEvent.MOUSE_DOWN, contin);
    
    function contin(event:Event):void {
    	gotoAndStop(2);
    }
    //
    FRAME 2:
    Code:
    //------------------------------------------------------------------------------------------------ 
    // Remove Loader off stage
    //------------------------------------------------------------------------------------------------
    
    removeChild(image_Content);
    //
    
    //------------------------------------------------------------------------------------------------ 
    // Bitmap
    //------------------------------------------------------------------------------------------------ 
    
    var imageA1:Bitmap;
    imageA1=new Bitmap(Bitmap(imageP1.content).bitmapData.clone());
    
    imageA1.x=200;
    imageA1.y=200;
    
    addChild(imageA1);
    //
    Attached Files Attached Files

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
  •  
HTML5 Development Center



Recent Articles