Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:22:52+00:00 2026-06-10T07:22:52+00:00

I have MC with external loaded image (jpg). Next layer is masked Sprite where

  • 0

I have MC with external loaded image (jpg).

Next layer is masked Sprite where I am drawing lines in different colors, opacity ,etc with graphics.lineStyle . Everything works fine, so I can see image and drawings over. Now I want eraser to make, and trying to make some kind of (transparent) line which will “erase” exising line.

If I for example draw (with mouse) red line, and then switch color to yellow and intersect on some point with previous line, it is ok, I see yellow color. Now I don’t have idea how to make “transparent” color? So when mouse move over existing drawing, just see again part of background image. If I set one color background everything is OK, but I have image, end eraser leaves some color, and I need to be transparent. Tried blend modes, cached as bmp, everything I found but still no solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:22:53+00:00Added an answer on June 10, 2026 at 7:22 am

    Seemingly you use Graphics objects that overlay the image. In order to erase something, you should give your sprite a topmost shape that will have BlendMode.ERASE as blend mode, and draw on it with alpha component of color being 0xFF. The sprite should have its blendMode to be BlendMode.LAYER. Here’s a test to play with:

    public class TestErase extends Sprite 
    {
        public function TestErase() {
            var b:Sprite = new Sprite();
            var c:Shape = new Shape();
            b.blendMode = BlendMode.LAYER;
            c.blendMode = flash.display.BlendMode.ERASE;
            c.graphics.beginFill(0, 1);
            c.graphics.drawRect(50, 50, 50, 50);
            c.graphics.endFill();
            b.graphics.beginFill(0xff0000, 1);
            b.graphics.drawRect(0, 0, 150, 150);
            b.graphics.endFill();
            b.addChild(c);
            addChild(b);
            this.graphics.beginFill(0x00c000, 1);
            graphics.drawRect(75, 75, 100, 100);
            graphics.endFill();
    
        }
    }
    

    This makes a 50×50 hole, defined by “c” sprite in “b” sprite, that does not affect “this” sprite.

    Okay you asked for an example. Here.

    public class Main extends Sprite 
    {
        public var sh:Shape;
        public var drawing:Boolean;
        public var sp:Sprite;
        public var bd:BitmapData;
        public var erasing:Boolean;
        [Embed(source = '../lib/093.jpg')]
        public static const Background:Class;
    
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
    
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            var ba:Bitmap = new Background();
            ba.scaleX = 0.5;
            ba.scaleY = 0.5;
            addChild(ba);
            bd = new BitmapData(640, 400, true, 0);
            var bm:Bitmap = new Bitmap(bd);
            sp = new Sprite();
            sp.addChild(bm);
            sp.blendMode = BlendMode.LAYER;
            var tf:TextField = new TextField();
            tf.y = 401;
            tf.background = true;
            tf.backgroundColor = 0x0;
            tf.defaultTextFormat = new TextFormat('Arial', 12, 0xe00000, true, false, false);
            tf.selectable = false;
            tf.text = 'Erase';
            addChild(tf);
            addChild(sp);
            tf.addEventListener(MouseEvent.CLICK, toggleErasing);
            sp.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
            sp.addEventListener(MouseEvent.ROLL_OUT, endDrawing);
            sp.addEventListener(MouseEvent.MOUSE_UP, endDrawing);
        }
    
        private function toggleErasing(e:MouseEvent):void {
            erasing = !erasing;
            if (erasing) (e.currentTarget as TextField).text = 'Erasing...'; else (e.currentTarget as TextField).text = 'Erase';
            e.stopPropagation();
        }
        private function startDrawing(e:MouseEvent):void {
            if (drawing) return;
            sh = new Shape();
            sh.graphics.lineStyle(3, Math.floor(Math.random() * 0x100000), 1,true);
            if (erasing) sh.blendMode = BlendMode.ERASE;
            sh.graphics.moveTo(e.localX, e.localY);
            addEventListener(MouseEvent.MOUSE_MOVE, trackMouse);
            sp.addChild(sh);
            drawing = true;
        }
        private function endDrawing(e:MouseEvent):void {
            if (!drawing) return;
            removeEventListener(MouseEvent.MOUSE_MOVE, trackMouse);
            if (erasing) bd.draw(sh, null, null, BlendMode.ERASE); 
            else  bd.draw(sh);
            sp.removeChild(sh);
            sh = null;
            drawing = false;
        }
        private function trackMouse(e:MouseEvent):void {
            sh.graphics.lineTo(e.localX, e.localY);
        }
    
    }
    

    Tested by me, and should work as is, just change the background 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a image loaded in a sprite, the image is from a remote
i actually try to do the following: I have loaded an external image in
I have a class (ImageLoader) that extends Sprite container and loads an external image
I have loaded an external URL in my WebView . Now what I need
I have external html5 canvas that you can paint on some lines using your
How can I open a jQuery colorbox with an external site loaded. I have
I have an external JavaScript in an asp.net 3.5 project. While writing different functions,
I have a firefox extension and I loaded an external javascript file to access
I have an image that has src pointing to an external server, like this:
I would like to have external proofreaders to work directly inside my Drupal site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.