actual target for MouseEvent.CLICK - spark skins

Hello

I have a question about events and events targeting listeners.

In my mobile AIR application, I need to click / tap on a number of s:Image objects.

As a first step, I added an event listener to each of them related to an event handler. Then try to optimize my code, I moved the event listener to the container object such as suggested in various optimization resources that I found online.

The problem was that the event.target property was not the image clicked, but a s:Group. I finally realized that the s:Group was part of the skin of the s:Image and I solved the problem by using the target.owner property, but this behavior has really created a lot of confusion. I couldn't find anything about this on the Adobe development resources, either as they just insist on (and explain very well) the difference between the target and currentTarget properties.

Below you will find a simple representation of my solution, but I was wondering if:

(1) this was actually due to a mistake I made, and whether it could be more easily avoided.

(2) there is a better or more effective than what I came up with.

(3) the topic is discussed somewhere in the documentation.

Thank you very much!

import spark.components.Image;

private var image1:Image;

private function initComponent():void
{
     image1 = new Image();
     image1.source = "assets/aaa.png";
     image1.id = "thisIsTheImage";
     addElement(image1);
                    
     addEventListener(MouseEvent.CLICK, clickHandler);          // 1
//   image1.addEventListener(MouseEvent.CLICK, clickHandler);     // 2 - the old one
}
               
private function clickHandler(event:MouseEvent):void
{
     trace("event.currentTarget \t\t\t" +              event.currentTarget);
     trace("event.target \t\t\t\t" +                   event.target);
     trace("event.target.owner.owner \t\t" +           event.target.owner.owner);
     trace("image1.imageDisplay.displayObject \t" +    image1.imageDisplay.displayObject);
     
     if(event.target.owner.owner is Image){
          // do something
     }
}

console:

event.currentTarget                     TestApp0.ViewNavigatorApplicationSkin2.navigator.ViewNavigatorSkin4.contentGroup.TestView33
event.target                            TestApp0.ViewNavigatorApplicationSkin2.navigator.ViewNavigatorSkin4.contentGroup.TestView33.SkinnableContainerSkin35.contentGroup.thisIsTheImage.ImageSkin43.Group44
event.target.owner.owner                TestApp0.ViewNavigatorApplicationSkin2.navigator.ViewNavigatorSkin4.contentGroup.TestView33.SkinnableContainerSkin35.contentGroup.thisIsTheImage
image1.imageDisplay.displayObject       TestApp0.ViewNavigatorApplicationSkin2.navigator.ViewNavigatorSkin4.contentGroup.TestView33.SkinnableContainerSkin35.contentGroup.thisIsTheImage.ImageSkin43.Group44

 

Simply set mouseChildren = false on the Images, and that any click on children will be recognized as a click on the Image.

HTH;

Amy

Tags: Flex

Similar Questions

  • MouseEvent.CLICK blocked by the child bitmap problem

    Hey guys.

    If anyone has experienced this problem or is sufficiently educated so that you can come up with a working solution then please post here.

    Good so for now I have 2 SWF files. A swf is the main swf, which contains a class called Avatar. This class extends Sprite and has 1 child, which is a bitmap image.

    What I do is load the child swf file into the main swf, create an object of the Avatar class and pass the Avatar object down to the child swf file.

    The child swf file takes this object and adds it to a Sprite object as one of its children. Then I add an event listener for MouseEvent.CLICK to Sprite (the one containing the Avatar sprite) object that is in the child swf file.

    Now when I click on the Avatar inside the Sprite image in the child swf file. Do not fire the mouse click event.


    If you can shed some light as to why this happens, I would be very grateful.

    Thank you.

    Difficult to say without seeing a code.

    As you describe it - it should work. How do you know that MOUSE_CLICK is not pulled?

    In addition, there are masks?

  • How to get event.target/event.currentTarget for HTML 5 canvas for Manager click

    Hello

    I hope that everyone else is doing great.

    I belong to bottom Actionscript and just started on CC Flash HTML 5 Canvas.

    How to get event.target and event.currentTarget in CC Flash for HTML 5 canvas for the click event.
    As we used to do an ACE 3.0

    btn.addEventListener (MouseEvent.CLICK, GB);

    function GB (evt:MouseEvent) {}

    trace ("evt-" + evt.currentTarget); It will let us know the selected target
    }

    For HTML-5

    btn.addEventListener ('click', go.bind (this));

    function GB (evt) {}

    Console.log ("evt-" + evt.? t); What is the correct syntax here?

    }


    Thank you


    Hey guys found the answer to stackoverflow

    It's - evt.target

  • Search or find target for shortcut missing features in Vista, deleted?

    I just finished a large number of documents, 7 GB, from my old XP computer to a new computer with Vista.  To avoid creating copies of the same file in this big folder structure I created often in many places shortcuts to point to the actual file.  Over the years, some of the structure of file modified and moved the target, so the shortcuts files are pointing to the old location.

    In Vista, whenever I've chaque fois que j' ai rencontre met one of these shortcuts pointing to the old location, by clicking the shortcut creates a "problem with shortcut" error and load the file fails.  In addition, if you right click on the shortcut properties, the button "find target" of XP has been replaced by "position to open the file" and it does not work as well.

    Under XP, it was never a problem.  I tested the old computer to make sure.  Whenever you click on a shortcut pointing to a location on the old XP automatically to find the file and resolve the reference shortcut, which loads the file with a slight delay only.  After closing the file the shortcut would now point to the new location.  The same thing will happen if you right-click the shortcut properties and chose the target of research, he finds the new loacation fairly quickly.

    Is there a reason for this 'Find target' for shortcuts feature has been disabled or deleted in Vista?  Is there a way to reactivate?

    I am running Vista SP1 with Windows Search 4.0.  Windows Search makes it quick to find the target file, but manually having to search and update each shortcut is going to be a real pain.

    I did some research and found this article that explains how to turn off this feature in XP and also to allow it.  I tried to create the same value of registry under Vista to see if it would, but it did not work:
    http://www.pcauthorities.com/Windows-XP/disable-missing-shortcut-search

    I also tried the .lnk associations found here:
    http://www.Winhelponline.com/blog/new-shortcut-Wizard-does-not-work-or-the-option-is-missing-in-Vista/

    Nothing seems to work.  What is it disabled for security or something?  Is there a way to set the shortcuts?

    This feature has been removed from Vista, why... I have no idea :(

    I hope that they (Microsoft) has added it back with Windows 7... which was released in October also ;)

  • How do you flash.control.label catch MouseEvent.CLICK?

    Hello

    Is it possible to catch mice of the flash label click event?

    mylabel.addEventListener (MouseEvent.CLICK, OnButtonClick);

    Does not work

    Or can it be done one is understood as

    SerializableAttribute public class monlabel extends fl.controls.Label
    {

    How to capture and send the mouse event?
    }

    Thanks for help.

    Is it a Label component or you mean dynamic text. It should work both as long as the name of the instance is mylabel.

    mylabel.addEventListener (MouseEvent.CLICK, OnButtonClick);

    function OnButtonClick(oEvent:MouseEvent):void

    {

    trace ('click of mylabel action');

    }

  • createToolTip and MouseEvent.CLICK on the ToolTip does not work

    Hello

    I didn't have success for a MouseEvent.CLICK working on a ToolTip created with ToolTipManager.createToolTip.

    Here is the code, no alert is displayed when I click on the ToolTip:

    private var tt:ToolTip;
    
    private function showToolTip( event:Event ):void
    {     
         tt = ToolTipManager.createToolTip( toolTipHelpText, 0 , 0 ) as ToolTip;
         tt.addEventListener( MouseEvent.CLICK, test )
    }
    
    private function test( event:MouseEvent ):void
    {
         Alert.show( 'test' );
    }
    

    Can I do something wrong?

    Thank you

    Set mouseEnabled = true on the ToolTip.  You may experience other side effects.  ToolTips are not necessarily designed for the mouse interaction

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • I upgraded to firefox 3.6 recently 11, but firefox11 works well with my windows 7. It became slow and strucks on for 6 seconds for each click.

    11 Firefox hangs frequently for about 6 seconds for each click as switching between tabs, closing tabs, opening new tabs.
    by clicking a link etc,
    3.6.17 worked well, but 11 Firefox is too slow.
    problem is the same with version 4 and 4.01
    can someone please help me to solve my problem

    I'm sorry that you have problems with Firefox doesn't work is not as fast as it should. I'd like to help you here so that you manage Firefox running at great speed.

    Firefox, try to start Firefox in Safe Mode. It temporarily disables your extensions, customizations, etc. so that we can see if they slow down Firefox. If Firefox works fine in Safe Mode, then it is probably a problem with the add-on. Restart Firefox in normal mode, and then type "subject: addons" (without the quotes) in the address bar. Disable your extensions, restart Firefox between each one, until you find the troublemaker. Once you do, you can disable this add-on.

    I also see you have advise McAfee Site. I would recommend disabling that, as it is known to cause leaks of massive memory than Firefox slow down

    If Safe Mode does not work, you can also try updating your graphics card driver. Update your graphics drivers to use hardware acceleration and WebGL reading can show you how to do this.

  • Pilot Windows 10 for Satellite click Mini L9W - B

    Hello!

    When about can we expect drivers for Windows 10 for Satellite click on mini? On the Toshiba Web page, I can only download drivers for Windows 8.1. That's why friends advised me to not install Windows 10 again. But how much time do we have to wait for Windows 10 pilots?

    Thank you very much!

    Hi Pete,.

    Keep an eye on this space.

    All drivers must be created and tested before Toshiba may make public, it is unfortunately a long and vigorous system, usually after a new operating system is released most of the products are made compatible within a year.

    Hope this helps,
    Z

  • Charge time for Satellite click Mini L9W - B

    I have another question:

    I noticed that in the first 5 months, the charge time for my click satellite mini was about 6-8 hours for two batteries. Now, it takes much more time. Currently, he is responsible for 13.5 hours and the keyboard battery is not yet completely load (I'll post the exact end time later...).

    There may be a problem or is this normal? I mean that the charging time has almost doubled...

    Thanks in advance

    AFAIK battery reach optimal performance, after some time of use... This means that the battery must be charged and discharged several times to reach the best level... but it also means that the battery charge time would increase...

    So from my point of few, there is no reason to fear that something could be wrong with the battery... you know...

  • Case for Satellite click on L9W Mini-B

    Was looking for a case for Mini click for a while, all I could find were netbook 10 "business that were too big. Came across this Case Logic

    It's a perfect fit, Tablet is very tight when zipped. On the inside of the case is a stand which folds that you could cut it with scissors, but the Tablet fits anyway so I don't bother, it adds extra padding.

    Hope it will be useful to others. Mine was bought on Amazon UK for £2.95, but I don't know there is no other sellers in the world.

    Message has been modified: commercial link has been removed

    Thanks for sharing!

  • Two fingers for secondary click tab does not work

    I had to create a new user profile, because in my old profile all the apple connected apps crashed when opening.

    My new user profile doesn't have this problem, but another: tab 2 fingers for secondary click does not work, even if it is selected in the trackpad options (System Preferences).

    I tried the usual off click / click back on, restart the computer, etc.. No change.

    Instead of secondary click, two fingers tab activates the scroll bar. I already disabled options scroll with two fingers, hoping that the problem would be a sort of interference, but again, no luck.

    Any ideas?

    I found my own solution and decided to publish it for anyone having a similar problem:

    When I activated the option "Ignore the trackpad when a mouse is connected" two-finger-click started working.

    I can't explain why (I do not use a mouse, so it shouldn't make a difference), but who cares, it works now.

  • Call the target for part Image

    The following code in fact handle bar my app a target for text sharing.

        
            Diaree
            icon.png
            application
            
                bb.action.SHARE
                text/plain
            
        
    

    But when I do the same with

    image/png
    image/jpg
    image/jpeg
    

    I don't see my application as a target in the image viewer share.

    I also tried

    *
    

    Who works for text, but not the images.

            
                bb.action.SHARE
            *
            
            
            
    
  • Application targeted for the 4.5 OS

    The application targeted for BB version 4.5, how does it work in BB version 5.0 and later. Will there be changes in the appearance of the user interface? The touch senstive features will be available to the general public to the application

    Hi Ramgopinath,

    Welcome to the BlackBerry support forums.

    No problem in the sense of coding etc., but if your application is targeted for only curved as devices that have screen resolutions (324 * 240), then the screens are may is unsuitable for 5.0 devices as "BOLD", storm.

    you will need to manage.

    As you know in 4.5 there is no contact, you must write the touch events for the buttons.

    Thank you.

  • Target for the connector to UNIX system user account

    Hello

    I have read the oracle... documentation in the doc stated as below...

    My question:

    We must create a normal user account in the Unix machine and add him to the sudoers group? or is there another method?

    Creating a user account target system SUDO for connector operations

    Oracle Identity Manager uses a system account target for reconciliation and provisioning operations execution. On all of the supported target systems, this account must be user root or sudo user.

    any input would be appreciated

    You can perform any activity necessary on the Unix machine so that the user can perform all actions with the sudo.  If you allow all orders, or only those required.

    -Kevin

  • [Logical diagram] Can I change my domain name target for relationship?

    I have a relationship 1: n between the two entities, say Parent-> child

    If the KP on the Parent is Parent_Id, the child then gets an automatic field named "Parent_Parent_Id".

    I want to name the field on the child (e.g. Daddy_Id), but could not find a way to do this.

    I put 'Name on the target' for Daddy_id, thinking that this would do the trick (it seemed obvious ), but it doesn't change anything to the child: there always Parent_Parent_id.

    I deleted and then recreated the relationship, nothing helps.

    What I am doing wrong? or is it not possible to do this (yet)?

    Note - it is sufficient, if this field has been created as DADDY_ID on the relational schema, but not even what's happening (even after the deletion of the table completely...)

    I hope this is a new feature in the months since I posted this question, but what I need do is now to open the properties of the target entity and change the attribute name

Maybe you are looking for

  • Get rid of Conduit search

    Whenever I update of Firefox, I am infected with Conduit search. It happened just update to 29 on my laptop and desktop. Getting rid of it is not as easy as to suggest answers in the forum, but I he would avoid rather than keep removing it. Does anyo

  • Use of Microsoft Bluetooth

    Hello I would like to know how can I be able to use Microsoft rather the toshiba one bluetooth adapters.The main idea is to be able to get Bluetooth phone and functionality of settings with windows where I can make calls using Windows and use the lap

  • After installing Windows 7, linking my old drive with Windows XP on it will let see me all the data in the drive?

    Original title: installation of Windows 7. I install Windows 7 on a new drive. My old drive is Windows XP and all my old data. IF I had to unplugging the old drive and install Windows 7 on the new drive and then plug the old drive and restart Windows

  • Impossible to get higher resolutions to 1080 p on my precision M3800

    My laptop M3800 screen is connected to the integrated graphics card Intel HD 4600 and can only display resolutions up to 1080 p. Of course, I would get the full resolution of 3200 x 1800. Running Windows 8.1. Any help appreciated.

  • Cannot set a default website in Google Chrome

    Hello Cannot set the default Web site in Google Chrome.  IE has been simply to go to the top of the page of google/right click / check the menu/internet options / and choose URL [google.com] to start by default. It is impossible for me to understand