dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Erasable image in AS3

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    12

    Erasable image in AS3

    There is a piece of code for erasing a mask with mouse in AS3
    Works perfectly. However, I need to detech if the whole image above is completely erased and if so, an action will take place such as "gotoAndplay(2)"

    Any idea how I can do that ?

    http://jonathannicol.com/blog/2009/0...-mouse-in-as3/

  2. #2
    Junior Member
    Join Date
    Jun 2015
    Posts
    1
    No one seems to have an answer to this question?
    It has been more than an year ago!

    I'm also looking for this solution, anyone?

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    If you have download the fla that is available from the link in the first post, then I can help you fix it.
    It is still in AS3 but I'm sure you could try to convert it to AS2 if needed.

    Find in the code:
    PHP Code:
    function stopDrawing(e:MouseEvent):void {
        
    doDraw=false;
        
    resumeDrawing false;

    and swap with this
    PHP Code:
    var topColor:uint 0xFFFFFFFF;
    var 
    emptyColor:uint 0x00000000;

    function 
    stopDrawing(e:MouseEvent):void
    {
        
    doDraw false;
        
    resumeDrawing false;
        var 
    bounds:Rectangle erasableBitmapData.getColorBoundsRect(topColor,emptyColor,false);
        if (
    bounds.width == && bounds.height == 0)
        {
            
    trace("empty");// no visible pixels on top
        
    }

    This will tell you if the top bitmap has disappeared totally or not when mouse up
    Last edited by fruitbeard; 06-09-2015 at 09:45 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