Skip to main content
Participant
November 5, 2009
Question

Edit bitmap from AS3

  • November 5, 2009
  • 2 replies
  • 3443 views

This will be my second post and the second problem

I create editable Bitmap with this code:

  • var myrequest:URLRequest = new URLRequest("images/bmp1.jpg");
  • var myloader:Loader = new Loader();
  • myloader.load(myrequest);
  • var myBitmapaData:BitmapData;
  • myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
  • function imgLoaded(e:Event):void{
  •     myBitmapaData = new BitmapData(myloader.width, myloader.height);
  •     myBitmapaData.draw(myloader);
  •     var Bmp:Bitmap = new Bitmap;
  •     Bmp.bitmapData=myBitmapaData;
  •     addChild(Bmp);
  • Everything has been very good loaded and I can see the efect in my swf. But the main thing that I want to do is fill the elements with different colors. I added listener to the stage, which has to do it, but it doesn't work:

    1. stage.addEventListener(MouseEvent.CLICK, FillObject);
    2. function FillObject(me:MouseEvent):void{
    3.         myBitmapaData.floodFill(mouseX,mouseY,0x55cc33);
    4.     }

    I haven't idea what is wrong. I should reload the picture ? If somebody have any idea I will be grateful.

    I found the way but it's not enough for me. I load the picture to the library and create the linkage. Than all is ok.

    1. var myBitmapData:kolorowanka1 = new kolorowanka1(839,598);
    2. var BMP:Bitmap = new Bitmap(myBitmapData);
    3. stage.addChild(BMP);
    4. stage.addEventListener(MouseEvent.CLICK, FillObject);
    5. function FillObject(me:MouseEvent):void{
    6.         myBitmapData.floodFill(mouseX,mouseY,0x55cc33);
    7.     }

    But I want to load pictures from disk.

    I attached rar with fla and picture.

    http://www.watchtime24.sisco.pl/moje/prace/FLASH/paint.rar

    Thans for all replies

    This topic has been closed for replies.

    2 replies

    Lee_Burrows
    Participating Frequently
    November 10, 2010

    if you have a solution please mark as answered

    kglad
    Community Expert
    Community Expert
    November 5, 2009

    what's the problem?

    michgorAuthor
    Participant
    November 5, 2009

    I don't want to have pictures in the library only load them from the disk. So the second way isn't good in may case. In the project I use the XML file and there I have path to picture.

    kglad
    Community Expert
    Community Expert
    November 5, 2009

    what's the problem with your first snippet of code that shows loading a bitmap?