Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Erase Multiple Layers in Flash Application?

New Here ,
Jul 25, 2014 Jul 25, 2014

So I am out-of-the-box new to AS3 programming, and I wanted to try out a tutorial.

I ended up using this one, and getting it to work properly: Erase an image using your mouse in AS3 | Jonathan Nicol

But now I want a few additions to the application, and have been tearing my hair out in attempting to get them to work.

If anyone can help me out, or direct me to where I can find out how to do any of the following, I'd be extremely grateful:

1. Being able to erase another image under the base image. So what you would have is first erasing the top image to reveal the middle image, then erasing the middle to erase the bottom. This could possibly go on for 6 or 7 layers.

     - Some sort of trigger that detects when a certain area has been  completely masked, so it can move on to the next image to erase?

2. A softer alpha brush? Just with something that doesn't seem so rigid when you erase

3. Some sort of regeneration property, in which after a certain amount of time the erased parted begin to slowly regenerate the image you're erasing.

4. Getting the image to be larger. I'm assuming that "400x400" line had something to do with it, but I wanted to make sure.

The second 3 aren't required, but would be appreciated if they were included, but I really need help with the first one.

Thank you for all the help!

TOPICS
ActionScript
414
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2014 Jul 25, 2014

1. assuming that's done by drawing to a mask, you can use the getColorBoundsRect method to determine if your mask is complete, or not:

var maskColor:uint = 0xFFFFFF;

var color:uint = 0xFF0000;  // <-if that's your mask color

var r:Rectangle;

var bmpd:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false);

function checkMaskF():Boolean{

    bmpd.draw(mask_mc);

    r = bmpd.getColorBoundsRect(maskColor, color, false);

    if(r.width==0 && r.height==0){

        return true;

    } else {

        return false;

    }

}

2. if you enable the cacheAsBitmap property of the mask and the masked movieclips, you can use an alpha gradient

3. don't now what you want

4.  the mask/masked sizes can vary and so can the brush size.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2014 Jul 26, 2014

First and foremost thank you for answering my question!

But I still am having trouble with my first problem.

See I'm trying to pull this off:

layers.png

But unfortunately no matter what I do, I can only get the first layer to erase.

Again, I've been using this tutorial: Erase an image using your mouse in AS3 | Jonathan Nicol

So is there any tweak that I can make to that script to get it to be able to erase layer 2 after the entirety of the first layer is erased? And can that tweak be applied so that I can continue erasing, say, 6 or 7 layers?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2014 Jul 26, 2014
LATEST

use the code in message 1 to determine when the unmasking of your 1st image (what you call layer 2) is complete.

then create a new empty mask and mask, what you call, layer 3 and draw to that new mask.

etc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines