get the color of a pixel on the stage

Is there a a way to retrieve the color of a generic pixel on the screen using the mouse inside the Flash Player scene? With the BitmapData class getPixel method you can get the color of a pixel as if the mouse is on a bitmap, but what happens if I need a generic pixel on the screen color?

Hello

You can take a snapshot of the scene and then get the color of the pixel from that.

function eventHandler(event:MouseEvent):void

{

var bmd:BitmapData = new BitmapData (stage.stageWidth, stage.stageHeight, false, 0x000000);

BMD. Draw (internship);

var pixelColour:uint = bmd.getPixel (event.stageX, event.stageY);

}

Tags: Adobe Animate

Similar Questions

  • question on the scope of the stage object

    Hello, all.  I am currently working with containers and I have a question about the stage object.

    I have 2 files in my program

    (1) app.as

    (2) stuff.as

    Stuff.As is a library of common user interface that I build.  I'm trying, in this document, follow these steps:

    stuff(){
    
    makeUI();
    
    }
    
    makeUI(){
    
    myContainer.setSize(stage.Stagewidth , stage.Stagehight);
    
    }
    

    Flash crash when running, saying that there is a reference not valid for a null object.

    If main.as is the file of the application, how can I get the stage object to be valid / available inside my stuff.as file?

    -Thanks for your time!

    Hey dtater,

    I met the same problem too in the past. the only way to have access to the stage is to have the class that never work added to the stage by a parent object that is already on scene. If an object has not yet been added to the stage, his stage value will be null.

    the best way to work with this set of return must have an event listener defined in your file stuff.as to listen for Event.ADDED event in your stuff() constructor like this:

    this.addEventListener(Event.ADDED, onAdded);
    

    and then in your event handler function onAdded:

    private function onAdded(e:Event):void{     // this event gets triggered by other objects, so we check to make sure it the right object     if (e.target == e.currentTarget)      {          makeUI();
    
         }
    
    }
    

    in this way the makeUI funciton only will be called when it has access to the scene.

    Here are more details on the event Event.ADDED:

    http://www.Adobe.com/LiveDocs/Flash/9.0/ActionScriptLangRefV3/Flash/events/event.HTML#added

    hope that helps. Good luck!

    Edit: I also forgot to add that the Event.ADDED event will be called when you addChild (stuff); in your main application.

  • How to get the color of a single pixel?

    Hi all.

    Part of my application is transparent. The other party is not.

    But I would like to have 'match' colors (is not very pretty orange to pink, but it's a matter of personal taste, I guess).

    That's why I need now to a background color.

    That's what I had in mind:

    Because we cannot get information about the currently active theme, I can do a screen capture and extract a single pixel of interest and get its color information. If it is green (for example) - I'll tryto use more Brown colors in my application.

    So basically, is it possible to get the color of a pixel in a bitmap (or something?)

    My last resort would be to save the Bitmap image to a file and then read that file.

    Bitmap.getARGB (int [] argbData, int offset, int scanLength, int x, int y, int width, int height)
    Gets the raw data ARGB region of this Bitmap and stores it in the table provided.

  • How to determine the color of a pixel on any given point on the screen?

    Does anyone know if it is possible to get the value of hexadecimal color of a pixel on the screen? And if yes how can I do this? I'm developing an application which can detect the color of an object in another (open) window and based on some steps. Any help with this would be greatly appreciated.

    Hey P-ylezc,

    You will need to use the call library function node to use GetPixel in LabVIEW.  Here is the document in the help file on the configuration of the node:

    http://zone.NI.com/reference/en-XX/help/371361F-01/lvexcodeconcepts/configuring_the_clf_node/

    In your case, copy the following code works:

    Note This is on 32-bit Windows, you may need to change this depending on what your system is.

  • How to get the background color of a layer with AE SDK

    Hello

    I try to get the background color for my current layer, but I can't seem to find how do.

    I don't want background color, background color of the application, but the color that shows through, if I set the alpha of my pixels to 0.

    For example, assume that the background of the composition is black, I put a solid top, green then put a picture on top of the solid and apply my pug-in the image.

    If I set the alpha to zero in my plug-in, green solid will be displayed.

    So I want to be able to know that my background is green.

    I tried to use PF_AppGetBgColor(), but which returns the background color of the application, which isn't green in this example.

    If you want more details on what I want to do, I plug P1 which affects some 0-alpha pixels. Above it, I apply an another plugin P2 which reveals alpha-0 pixels by mixing with little color.

    What is happening now is that the output is color of the original image, mixed with the color of P2 (because only modified P1 alpha pixels).

    What I want is to have the color through the transparent pixels of P1 display mixed with the color of P2.

    To do this, I would like to be able to set the color of pixels 0-alpha in the color of the background in P1.

    Sorry for the question long.

    Thanks for your suggestions.

    Hello nicolas.

    If I understand it, that you try to get the buffer of image layers composited under the layer with your effect.

    If that is correct, then I fear that it is almost impossible to do.

    When AE makes a composition he doesn't it down. He's trying to do the opposite in fact.

    Why? because if at some point, the buffer is completely opaque, then he has no need to make what's below.

    further more, checked the diaper changing the rendering order, and many other things affect the rendering of the layers order.

    In addition, there is no API to access buffers intermediaries comp. just the end result.

    the closest you can get than without turning of the world, is to use AEGP_GetCompBGColor().

    that would be useless to you that the image is not composite on that color, unless it is the model being saved to the file.

    so why I said 'almost impossible '?

    You can transform the world.

    You can write a type ECAP 'craftsman '. (look at the example of 'arti')

    These plug-ins make comps (instead of the "advanced3D" converter)

    a craftsman has results intermediaries comp, because he is the one doing the rendering.

    so now you can have your craftsman save the buffer, you need and deliver it to your effect.

    I must warn you that this is very very very difficult.

    Another possible solution is to create a copy of the model resides in your effect,

    erase all the layers that has the image you need and make that reproduces model using AEGP_GetReceiptWorld().

    If you use this method, you must supervise the original model and apply changes to the copy.

    Yes, it's too difficult to do.

    you could make a change in the strategy and apply your effect to an adjustment layer instead.

    the entry for the adjustment layer is the buffer underlying layers.

    Then, you could get the original sources you want to treat using checked layer params.

    the last solution I can think uses the expression of sampleImage() on a hidden parameter.

    This will give you any layer's pixel data in the model, but not the composite of the underlying layers.

    Maybe if you tried sampling adjustment layers post effects... I don't know. you need to try.

    This method is very slow and is also limited to expire, so you can't get a large number of pixels.

    the expression simply fails.

    I hope that this was not all bad news for you.

    Maybe you said more about the plug-in you develop I could come up with a better plan.

    :-)

  • How can I get the tabs colorful to use different distinct colors for 2 gmail accounts?

    Under Firefox 29.0.1 iMac OSX 10.9.3. I have multiple Google accounts: 2 1 Google Calendar and gmail accounts. Colorful tabs add-on will allow me to choose a color for a gmail account, but it also uses this same color for the other gmail account. How can I get the different colors on 2 gmail accounts?

    In addition, colorful tabs is also the same for my homepage (google.com) and my google calendar. How can I get different colors on these 2?

    Personally, I use 'Fabtabs' for my mozilla FireFox.

    https://addons.Mozilla.org/en-us/Firefox/addon/FabTabs/

    This add-on has problems like that when I use it.

  • get the dimensions in pixels of office?

    How can I query the findout the dimensions of the screen desktop system, the program runs on?

    I need to popup a window full-screen without borders, up to now, I had control of the hardware, so I know that the resolution of the screen (1920 x 1200), but there is interest in a system of "just an application" so I have to deal appropriately with different (probably smaller) resolutions pixels maximum.

    This window is basically a canvas tile controls programmatically created the only real question is so get the size of the screen running and creating tiles or print a message of error if the screen is too small for use (i.e. 800 x 600)

    -wally.

    int i, [9] w = {0}, [9] h = {0}, Nmonitors, monitor first, primary, [10] = {0}, albums [9] = {0}, left [9] = {0};

    GetSystemAttribute (ATTR_NUM_MONITORS & Nmonitors);
    GetSystemAttribute (ATTR_PRIMARY_MONITOR, & primary);
    GetSystemAttribute (ATTR_FIRST_MONITOR, &first);)
    Monitor [0] = first;
    for (i = 0; i<>
    GetMonitorAttribute (monitor [i], ATTR_NEXT_MONITOR, & monitor [i + 1]);
    GetMonitorAttribute (monitor [i], ATTR_HEIGHT, &h[i]);)
    GetMonitorAttribute (monitor [i], ATTR_WIDTH, &w[i]);)
    GetMonitorAttribute (monitor [i], ATTR_TOP, & top [i]);
    GetMonitorAttribute (monitor [i], ATTR_LEFT, & left [i]);
    }

    Thanks, the code snippet above seems to have all the info that I need to use only the CVI calls.  I usually mix CVI and Win32 call anyway, but this avoids having to dig up the documentation on the Win32 structure typedefs.

    Thanks for the links to the Win32 multi-monitor documentation.

    -wally.

  • How to get the background color setting after accidentally change?

    Original title: background and other color changes
    I changed the background color by accident and cannot get the original settings that I had back

    Hello

    1. who is the operating system installed on the computer?
    2. what was the background color and what color you have changed from?
    3. What are other color changes you're talking about?
    4. What are the steps you did to change the background color?
     
     
    If you work on a windows 7 OS then try the steps in the following article and check the status of the issue.
     
     
    I hope this helps!
  • How to get the bar display of title in pixels text length?

    Hello

    Does anyone know how to get the length of the title bar text (in pixels) display?  Just to clarify, that's what I'm looking for:

    I don't see a CVI function for this.  The attribute ATTR_TITLE_FONT for GetPanelAttribute (...) is only valid for the panels of the child which prevents me from using the GetTextDisplaySize (...) to get the size.  Dive into the Windows SDK I can not even find an answer here.  Any ideas?  Thank you.

    Figured out how to do this.  Go to the SDK to get the font properties - is kind of nonobviousness.  But once you have the font properties, you can create a font of meta in CVI, with properties, and once you have the meta font you can use GetTextDisplaySize (...) to get the size.  For any future reference:

    //define a NONCLIENTMETRICS structureNONCLIENTMETRICS ncmtest;//We have to set the cbSize parameter to the size of the passed structure before retrieving it
    ncmtest.cbSize = sizeof(NONCLIENTMETRICS);
    //Get NONCLIENTMETRICS structure
    result = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncmtest, 0);
    
    //copy the title font name to a c-string
    while(ncmtest.lfCaptionFont.lfFaceName[i] != 0)
    {
        thefont[i] = (char)ncmtest.lfCaptionFont.lfFaceName[i];
        ++i;
    }
    
    //null terminate
    thefont[i] = '\0';
    
    //create meta font with title font properties.  lfWeight & 0x700 indicates bold.  CreateMetaFontWithCharacterSet() doesn't recognize DEFAULT_CHARSET so we replace it with VAL_NATIVE_CHARSET(?).
    uir_status = CreateMetaFontWithCharacterSet ("TheTitleFont", thefont, abs(ncmtest.lfCaptionFont.lfHeight), ncmtest.lfCaptionFont.lfWeight & 0x700 ? 1 : 0, ncmtest.lfCaptionFont.lfItalic, ncmtest.lfCaptionFont.lfUnderline, ncmtest.lfCaptionFont.lfStrikeOut, 0, ncmtest.lfCaptionFont.lfCharSet == DEFAULT_CHARSET ? VAL_NATIVE_CHARSET : ncmtest.lfCaptionFont.lfCharSet);
    
    //get titlebar text
    uir_status = GetPanelAttribute (panelhandle, ATTR_TITLE, thetext);
    //get title bar length
    uir_status = GetTextDisplaySize (thetext, "TheTitleFont", &height, &width);
    

    I have a 79 for the duration of the screenshot above.

  • Could not get the matrix of pixels per 'ImageToArray' VI...

    I have run the 'ImageToArray' example, but you see, I can't get the matrix of pixels in the image.

    could someone help me?

    Thank you very much!

    I deal with problems, thank you!

  • printer Lexmark Pro 200. Does not print the correct colors. I restarted my computer and the printer is off but get the same result.

    Printer Lexmark Pro 200.  Does not print the correct colors. I restarted my computer and the printer is off but get the same result.

    Hello

    • What were the changes made before the problem occurred?

    You try to run this fix and check.

    http://Windows.Microsoft.com/en-us/Windows7/open-the-printer-Troubleshooter

    If above does not work, try contacting Lexmark support for assistance.

    http://www1.Lexmark.com/en_US/global-services/customer-support-services/index.shtml

  • How can I get the color codes for the notebook

    How can I get the color codes for the notebook?

    Hello

    What is the color codes for the notebook?

    Perhaps you need a 3rd party utility like GetDiz - Free and others to be
    found using BING or Google.

    GetDiz Notepad - free - replacement
    http://www.Outertech.com/en/Notepad-replacement

    I hope this helps.

  • get the data in the table of the image in pixels

    Ma, I have an array of image which I am using gerargb() method now in the table there are data, but how do I get the particular pixel data how this table to store image. Hitesh gs

    If your image is 20 * 10 - 20 pixels wide and 10 pixels tall, so you have a 20 * 10 == 200 input array.

    Pixels are numbered from the top left corner.  If the index

    0 - is the upper left corner

    199 - is the lower right corner,

    (x * 20) + y--is the pixel x (x is in the range 0 through 9) online, column y (there is in the range 0-19.  Do not forget that this countdown of the top left corner.

    Claire?

  • Problem to get the background color

    Mr President, in my code, I wasn't able to use fully all the width of the screen,

    This is my code

    public class HorizontalField extends VerticalFieldManager
    {
       HorizontalFieldManager sd=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
       HorizontalFieldManager r1=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
       MySeparatorField ds=new MySeparatorField();
       Font fnt,fntv;
        HorizontalField()
        {
           fnt = this.getFont().derive(FontFamily.SCALABLE_FONT, 14);
           fntv = this.getFont().derive(FontFamily.SCALABLE_FONT, 11);
           r1.setFont(fntv);
           /*---------------------Heading-----------------------------------*/
           DateField dd=new DateField("Date");
    
           dd.setFont(fnt);
           sd.add(dd);
          /*------------------*/
           MyLine s=new MyLine();
           sd.add(s);
           Desp d1=new Desp("Description");
           d1.setFont(fnt);
           sd.add(d1);      
    
           /*_________________*/
           MyLine s1=new MyLine();
           sd.add(s1);
    
           Amt d2=new Amt("Amount");
           d2.setFont(fnt);
           sd.add(d2);
           add(new SeparatorField());
           add(sd);
           add(new SeparatorField());
    
               DateField dfr=new DateField("13.08.09")
               {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(dfr);
               MyLine sr=new MyLine();
               r1.add(sr);
               Desp dr=new Desp("Reent")
               {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(dr);
               MyLine sra=new MyLine();
               r1.add(sra);
               Amt amtr=new Amt("5000")
                 {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(amtr);
               add(r1);
               add(new SeparatorField());
    
           }
    
        }
    
     class DateField extends LabelField
    {
         DateField(String s)
        {
            super(s,LabelField.LEFT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*2/10;
        }
    
    }
    
      class Desp extends LabelField
    {
         Desp(String s)
        {
            super(s,LabelField.RIGHT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*5/10;
        }
    
    }
    
      class Amt extends LabelField
    {
        Amt(String s)
        {
            super(s,LabelField.RIGHT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*4/10;
        }
    
    }
    

    MyLine code is

    public class MyLine extends LabelField
    {
        int width,height;
    
        ButtonField dd;
        MyLine()
        {
            width=1;
            //height=200;
        }
         MyLine(int w)
        {
            width=w;
            //height=200;
        }
    
         public int getPreferredWidth()
            {
                return width;
             }
    
         public void paint(Graphics g)
                {
                       // g.setBackgroundColor(Color.BLUE);
    
                     g.drawLine(0,0,0,70);
                }
    }
    

    When I call this HorizontalField I get the result, but in the amount column (i.e. red) background color I get half of this label, I don't know what problem I did

    Thank you

    The problem is in your calculation of width.

    Your should calculate your width in such a way that (approximate):

    Display.getWidth () = DateField width, width PED, Amt width + 2 * MyLine width;

    Furthermore, a solution may be simply change your constructor Amt class as below:

            Amt(String s)        {                   super(s,LabelField.RIGHT | Field.USE_ALL_WIDTH);        }
    

    Concerning

    Bika

  • Get the color system of the focus/theme

    Hello

    I want to emphasize text in a CheckboxField with the highest development/point system color / theme. I know that I could get forefront and background easily colors in the graphics but y at - it a way to get the update/point system color climax / theme?

    Today I have this code but the rendering is ugly quiet (black & white):

    CheckboxField cbField = new CheckboxField("test", true) {    protected void paint(Graphics g) {        if(this.isFocus()) {          int fcolor = g.getColor();            int bcolor = g.getBackgroundColor();          g.setColor(fcolor);           g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 8, 8);           g.setColor(bcolor);       }     super.paint(g);   }
    
    };add(cbField);
    

    Kind regards

    Sylvain.

    These colors are not currently exposed in the API set BlackBerry.

Maybe you are looking for