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 6542377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:13:11+00:00 2026-05-25T11:13:11+00:00

I’m trying to make a image editor in Flex 4.5. However, there’s one little

  • 0

I’m trying to make a image editor in Flex 4.5.

However, there’s one little thing that doesn’t work as appropriate. Here’s my code:

            private function returnCropIndicatorBmpDataForTopLeft():BitmapData{

            var topLeftX:int     = 0;
            var topLeftY:int     = 0;

            var topRightX:int    = _bmpData.width;
            var topRightY:int    = 0;

            var bottomRightX:int = _bmpData.width;
            var bottomRightY:int = _bmpData.height;

            var bottomLeftX:int  = 0;
            var bottomLeftY:int  = _bmpData.height;

            var cropIconX:int    = _mouseX;
            var cropIconY:int    = _mouseY;

            var temporaryBitmapData:BitmapData = _bmpData;

            var originalColor:uint;
            var dimmedColor:uint = 0x202020;

            for (var i:int = 0; i < _bmpData.width; i++) 
            {
                for (var j:int = 0; j < _bmpData.height; j++) 
                {
                    originalColor = _bmpData.getPixel(i,j);

                    if(i>cropIconX && j>cropIconY){
                        temporaryBitmapData.setPixel(i,j,originalColor);
                    }else{
                        temporaryBitmapData.setPixel(i,j,dimmedColor);
                    }
                }
            }
            /*
            *by the end of this loop, we have, in the temporaryBitmapData variable, a version of the _bmpData,
            *the area to be cropped out dimmed a little bit.
            */

            return temporaryBitmapData;
        }

if you look carefully inside the first if statement in the innermost for loop,

temporaryBitmapData.setPixel(i,j,originalColor);

that bit of code should do the following:

If this (i,j) pixel is outside of the “to-be-cropped-out area”, then repaint it with the original pixel color.

It just can’t seem to get that to work!!!!

I’ve substituted that line with some hardcoded value (say, 0xFFFFFF for white) and it did work, so the problem is not there….

Hope you guys can help me out I’ve spent more than 4 hours on this already trying many different approaches!!

P.S.> I debugged this code in FB 4.5 and placed a breakpoint in that very if statement. For some reason, the _bmpData variable, which is where I want to get the original pixel color from , shows a small red square next to it…. Perhaps that is indicative of something.. perhaps it’s somehow thread-‘locked’?? I don’t know, hope someone can figure out!

EDIT the problem I’m having is the following: the dimming of the image works fine, but if I then move the mouse cursor back to an area that got dimmed out, then the original image doesn’t get repainted, as expected.

  • 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-05-25T11:13:12+00:00Added an answer on May 25, 2026 at 11:13 am

    There must be something else going on there… I just tested your code and it worked fine for me.

    package  {
    
        import flash.display.MovieClip;
        import flash.display.BitmapData;
        import flash.display.Bitmap;
        import flash.net.*;
        import flash.display.Loader;
        import flash.events.Event;
    
        public class ImageCropper extends MovieClip {
    
            protected var _bmpData:BitmapData;
            protected var _mouseX:int;
            protected var _mouseY:int;
            var imageLoader:Loader;
    
            public function ImageCropper() {
                _mouseX = 80;
                _mouseY = 50;
                imageLoader = new Loader();
                var image:URLRequest = new URLRequest("http://www.travelooce.com/pics/bear_picnic_table.jpg");
                imageLoader.load(image);
                imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, _imageLoaded);
                imageLoader.x = 0;
                imageLoader.y = 0;
    
            }
    
            public function _imageLoaded($evt:Event):void {
                _bmpData = new BitmapData(imageLoader.width, imageLoader.height, false);
                _bmpData.draw(imageLoader);
                var bmp2:BitmapData = returnCropIndicatorBmpDataForTopLeft();
                var bmp:Bitmap = new Bitmap(bmp2);
                addChild(bmp);
            }
    
            private function returnCropIndicatorBmpDataForTopLeft():BitmapData{
    
                var topLeftX:int     = 0;
                var topLeftY:int     = 0;
    
                var topRightX:int    = _bmpData.width;
                var topRightY:int    = 0;
    
                var bottomRightX:int = _bmpData.width;
                var bottomRightY:int = _bmpData.height;
    
                var bottomLeftX:int  = 0;
                var bottomLeftY:int  = _bmpData.height;
    
                var cropIconX:int    = _mouseX;
                var cropIconY:int    = _mouseY;
    
                // This is the important line to change.
                var temporaryBitmapData:BitmapData = _bmpData.clone();
    
                var originalColor:uint;
                var dimmedColor:uint = 0x202020;
    
                for (var i:int = 0; i < _bmpData.width; i++) 
                {
                    for (var j:int = 0; j < _bmpData.height; j++) 
                    {
                        originalColor = _bmpData.getPixel(i,j);
    
                        if(i>cropIconX && j>cropIconY){
                            temporaryBitmapData.setPixel(i,j,originalColor);
                        }else{
                            temporaryBitmapData.setPixel(i,j,dimmedColor);
                        }
                    }
                }
                /*
                *by the end of this loop, we have, in the temporaryBitmapData variable, a version of the _bmpData,
                *the area to be cropped out dimmed a little bit.
                */
    
                return temporaryBitmapData;
            }
        }
    
    }
    

    Output:

    http://cl.ly/3d0h023C1p392O270I2Lenter image description here

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.