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

Edit bitmap from AS3

New Here ,
Nov 05, 2009 Nov 05, 2009

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

    TOPICS
    ActionScript
    3.3K
    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 ,
    Nov 05, 2009 Nov 05, 2009

    what's the problem?

    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 ,
    Nov 05, 2009 Nov 05, 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.

    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 ,
    Nov 05, 2009 Nov 05, 2009

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

    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 ,
    Nov 05, 2009 Nov 05, 2009

    ok you didn't understand my problem. First code is correct, it loads the btimap, but I want fill this bitmap with the colors. I use to this floodFill() but it dosn't work in first case.

    This function:

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

    doesn't change the color of area when I click the mouse why ?

    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 ,
    Nov 05, 2009 Nov 05, 2009

    I found the answer ! floodFill require ARGB, so I changed color to 0xFF55cc33 and it works.

    Thanks for replies

    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 ,
    Nov 05, 2009 Nov 05, 2009

    you're welcome.

    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
    Advocate ,
    Nov 10, 2010 Nov 10, 2010
    LATEST

    if you have a solution please mark as answered

    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