UI Event Targetting

I've got an application running under SE 1.4.1 and SE 1.4.2 on Windows 98 and I'm getting an problem whereby mouse presses, releases and clicks are not being forwarded to the correct components.
The problem is fairly easy to replicate and pressing the right mouse and middle mouse buttons a few times seems to fix the problem, but isn't a solution I want to have to live with.
The app. below was run and the dialog shown (just press the button on the frame). The tree nodes on the dialog were all expanded and the viewport scrolled up and down several times with the mousewheel. This then stops the mouse clicks working.
package app;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Frame extends JFrame implements AWTEventListener, ActionListener
    private JDialog dlg = null;
    public static void main(String[] args) throws HeadlessException
        Frame frame1 = new Frame();
        frame1.show();
    public Frame() throws HeadlessException
        setSize(new Dimension(800, 400));
        JButton button = new JButton();
        button.setText("Show Dialog");
        button.addActionListener(this);
        getContentPane().setLayout(new FlowLayout());
        getContentPane().add(button, null);
        Toolkit tk = getToolkit();
        tk.addAWTEventListener(this, MouseEvent.MOUSE_CLICKED + MouseEvent.MOUSE_PRESSED + MouseEvent.MOUSE_RELEASED + MouseEvent.MOUSE_EXITED + MouseEvent.MOUSE_ENTERED);
    public void eventDispatched(AWTEvent event2)
        if (event2.getID() == MouseEvent.MOUSE_CLICKED)
            MouseEvent me = (MouseEvent)event2;
            System.out.println("Click: " + me.getX() + ", " + me.getY() + " " + me.getButton() + " orig@" + me.getComponent().getClass().getName());
        else if (event2.getID() == MouseEvent.MOUSE_PRESSED)
            MouseEvent me = (MouseEvent)event2;
            System.out.println("Press: " + me.getX() + ", " + me.getY() + " " + me.getButton() + " orig@" + me.getComponent().getClass().getName());
        else if (event2.getID() == MouseEvent.MOUSE_RELEASED)
            MouseEvent me = (MouseEvent)event2;
            System.out.println("Release: " + me.getX() + ", " + me.getY() + " " + me.getButton() + " orig@" + me.getComponent().getClass().getName());
        else if (event2.getID() == MouseEvent.MOUSE_ENTERED)
            MouseEvent me = (MouseEvent)event2;
            System.out.println("Enter: " + me.getX() + ", " + me.getY() + " " + me.getButton() + " orig@" + me.getComponent().getClass().getName());
        else if (event2.getID() == MouseEvent.MOUSE_EXITED)
            MouseEvent me = (MouseEvent)event2;
            System.out.println("Exit: " + me.getX() + ", " + me.getY() + " " + me.getButton() + " orig@" + me.getComponent().getClass().getName());
    public void actionPerformed(ActionEvent ae)
        if (ae.getActionCommand().equals("Show Dialog"))
            //show the dialog
            dlg = new JDialog();
            dlg.setModal(true);
            dlg.getContentPane().setLayout(new BorderLayout());
            JScrollPane sp = new JScrollPane(new JTree());
            dlg.getContentPane().add(sp, BorderLayout.CENTER);
            JButton button = new JButton("Close Dialog");
            dlg.getContentPane().add(button, BorderLayout.SOUTH);
            button.addActionListener(this);
            dlg.setSize(new Dimension(200, 200));
            dlg.show();
        else if (ae.getActionCommand().equals("Close Dialog"))
            //close the dialog
            dlg.hide();
}Compiling and running the above gave this logging in the console which shows when the mouse entered a component, when it exits a component and when the mouse is pressed, released and clicked over a component:
Enter: 136, 262 0 [email protected]
Exit: 136, 264 0 [email protected]
Enter: 136, 0 0 [email protected]
Exit: 142, -2 0 [email protected]
Enter: 142, 262 0 [email protected]
Exit: 142, 260 0 [email protected]
Enter: 141, 259 0 [email protected]
Exit: 145, 261 0 [email protected]
Enter: 146, 262 0 [email protected]
Exit: 146, 264 0 [email protected]
Enter: 146, 0 0 [email protected]          <--(mouse moved on to button)
Press: 154, 299 1 [email protected]        <--(mouse pressed)
Release: 154, 299 1 [email protected]      <--(mouse released)
Click: 154, 299 1 [email protected]        <--(mouse click happens)
Exit: 148, -6 0 [email protected]          <--(now move off the button)
Enter: 147, 257 0 [email protected]
Exit: 15, -11 0 [email protected]
Enter: 40, 3 0 [email protected]
Exit: 157, 273 0 [email protected]
Enter: 158, 10 0 [email protected]            
Exit: 168, 26 0 [email protected]
Press: 259, 464 1 [email protected]
Release: 259, 464 1 [email protected]
Click: 259, 464 1 [email protected] can clearly be seen, the event for the mouse moving over the various components has the correct source (the button or tree) but when the mouse is pressed while over the button, the event comes through with the source as the dialog beneith the button.
I've searched the bug database but can't find anything about this, but my test app above should not be able to cause this error.
Any ideas how to fix this?

Hope this will help:
var myList = ["Item 1","Item 2","Item 3","Item 4","Item 5","Item 6","Item 7","Item 8","Item 9","Item 10"];
var win = new Window('dialog', 'myDlg');
var ddL = win.add('dropdownlist',undefined,myList);
ddL.onChange = function(){alert("Item changed");}
win.center();
win.show();
tomaxxi
http://indisnip.wordpress.com/

Similar Messages

  • How do I use the event.target.name String with an external dispatchEvent?

    ...I hope the title question makes sense...
    On my stage I have an externally loaded SWF with a button. When clicked the button dispatches an event to the main stage.
    On the main stage a listener then loads an SWF into a loader called gallery.
    The gallery loader is also being shared by buttons on the main stage which use the event.target.name String to call in SWFs with corresponding names.
    I am using Tweens to fade-out and -in content to the gallery when a button is pressed.
    Loading the SWFs was working until I tried to create a universal button function for the dispatchEvent buttons...
    The problem I have is that I don't know how to define the String to tell the newSWFRequest where to find the SWF when triggered by the external buttons.
    (I may be doing this all wrong... but figured the best way to load an SWF on to the main stage from an external SWF was by using dispatchEvent??)
    My code triggers the Event and the gallery loader fades out, but then it cannot find the new SWF:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
    Please can someone help me understand the way to make the String point in the right direction? (I think the only errors are in bold below)
    Code:
    var myTweenIn2:Tween;
    var myTweenOut2:Tween;
    var nextLoadS2:String;
    // Listen for external event dispatched from external btns
    addEventListener("contactStage", btnClickExtrnl);
    function btnClickExtrnl(e:Event):void {
    nextLoadS2 = ?????
    myTweenOut2=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOut2.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    // Btns Universal function
    function tweenOutCompleteF2(e:TweenEvent){
    myTweenOut2.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    myTweenOut2=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + nextLoadS2 + ".swf");
    myTweenIn2 = new Tween(gallery, "alpha", None.easeOut, gallery.alpha, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    Thank you.

    That works – thank you!
    I'm now using this code to fade in each of the SWFs:
    function contactStage(e:MouseEvent):void {
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
        myTweenIn = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But I cannot add the fade out function. I have amended the above code to create:
    var myTweenOutX:Tween;
    var myTweenInX:Tween;
    function contactStage(e:MouseEvent):void {
    myTweenOutX=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOutX.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    function tweenOutCompleteFX(e:TweenEvent){
    myTweenOutX.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    myTweenOutX=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
    myTweenInX = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But get this error:
    ReferenceError: Error #1069: Property name not found on fl.transitions.Tween and there is no default value.
    at ACOUSTIC_fla::MainTimeline/tweenOutCompleteFX()[ACOUSTIC_fla.MainTimeline::frame1:110]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.transitions::Tween/set time()
    at fl.transitions::Tween/nextFrame()
    at fl.transitions::Tween/onEnterFrame()
    Where am I going wrong?

  • How do I use event.target.name in AS2?

    Thanks to kglad I was able to see how event.target.name in AS3 could make a button load a movieclip with the same namesake.
    I'm doing the same thing now in AS2 but don't know what to write instead of event.target.name.
    And so at the moment each button pushes info into an array and then a function uses that to decide which movieclip to attach to a holder after it has faded out once, and then fades in again...
    // ***** IMAGE GALLERY START ***** //
    // Add image to holder
    imgholder.attachMovie("img0", "image0_0", 1)
    // Array
    var nextLoad = ["img0"];
    // Btn listeners
    img5.onRelease = function() { trace (nextLoad); nextLoad.pop(); nextLoad.push("img5"); btnClick() } // Written on 1 line
    img4.onRelease = function() { trace (nextLoad); nextLoad.pop(); nextLoad.push("img4"); btnClick() }
    img3.onRelease = function() { trace (nextLoad); nextLoad.pop(); nextLoad.push("img3"); btnClick() }
    img2.onRelease = function() { trace (nextLoad); nextLoad.pop(); nextLoad.push("img2"); btnClick() }
    img1.onRelease = function() {
    nextLoad.pop();
    nextLoad.push("img1");
    btnClick()
    img0.onRelease = function() {
    nextLoad.pop();
    nextLoad.push("img0");
    btnClick()
    // The btn function
    function btnClick() {
    trace ("click");
    var myImgTween:Object = new Tween(imgholder, "_alpha", Strong.easeOut, 100, 0, 1, true);
    myImgTween.onMotionFinished = function() {
    fadeOutImg();
    // The btn function part II
    function fadeOutImg() {
    trace ("fadeOutImg");
    imgholder.attachMovie(nextLoad, "image1_1", 1);
    var myImgTween:Object = new Tween(imgholder, "_alpha", Strong.easeOut, 0, 100, 1, true);
    I know I should be able to push the button name into the array, but am having to use a string... I'm sure my code is cumbersome!! But it works. I've tried pushing the button name but it end up including the full stage reference.
    Is there a cleaner way of doing this using event.target.name?
    Thanks for looking!

    There is no event.target in AS2. However since AS2 has no way of remembering the scope object where the target object resides, you can use this to your advantage to retrieve the name of the target by using the "this" command in the function whenever you use the above format "mc.onPress = myfunc". FYI, the popular workaround Delegate, made it possible that when you called "this" in the function, you could retrieve the scope object where the target instance resides. So without its use, "this" will return the name of the target object. Anyway this is the code you can use:
    imgholder.attachMovie("img0","image0_0",1);
    var nextLoad = ["img0"];
    img5.onRelease = onImgRelease;
    img4.onRelease = onImgRelease;
    img3.onRelease = onImgRelease;
    img2.onRelease = onImgRelease;
    img1.onRelease = onImgRelease;
    img0.onRelease = onImgRelease;
    function onImgRelease():Void {
       nextLoad.pop();
       nextLoad.push(this._name);
       btnClick();
    // The btn function
    function btnClick() {
       trace("click");
       var myImgTween:Object = new Tween(imgholder, "_alpha", Strong.easeOut, 100, 0, 1, true);
       myImgTween.onMotionFinished = function() {
          fadeOutImg();
    // The btn function part II
    function fadeOutImg() {
       trace("fadeOutImg");
       imgholder.attachMovie(nextLoad,"image1_1",1);
       var myImgTween:Object = new Tween(imgholder, "_alpha", Strong.easeOut, 0, 100, 1, true);

  • AS 3.0 how to set event target?

    Hi,
    I am trying to execute an event on a specific target and I am
    not successful in doing this in AS 3.0 since event.target is read
    only. Here is the scenario:
    - I have a button and the path to this button is:
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    I know this because I did install a listener to and when I
    clicked I recorded the path.
    - I would like to execute a click programmatically on that
    path by just creating an event and setting the target to that
    button
    (DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104)
    however I don’t know how to set the target. Can anybody help
    or point me to the right direction so I can do this.
    Thanks…

    zoran,
    Sorry,I didn't explain what to do very clearly :).
    Básically, the event.taget parameter is set when you use the
    dispatchEvent function, so if you want an event to be dispatched
    from a Object you must call the dispatchEvent from this function.
    The line I gave you wont work by itself since I don't know
    how you reference
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    in your application.
    But what you need to do is call the dispatchEvent function in
    the Button104 object with the specific event you want to trigger.

  • Event.target == null in AIR client

    Hello,
    once again I have a question, and this may very well be a tricky one:
    I have the need to check if a dynamic XFA form has been signed from inside this form. This is quite easy and works perfectly if I just use a button on the form or just about any script event I can think of. It does, however, NOT work if I use the form inside an AIR client which is using a FormBridge construction to communicate with the PDF.
    The problem seems to be that event.target is always null in that case. So what I'm looking for is either an explanation why event.target is null when embedding the form inside AIR or how to check if the form is signed without having to use event.target (or the doc object if you will).
    Can anyone think of anything to achieve this?
    Many thanks,
    Steffen.

    Here is the site: http://coenraets.org/blog/2009/12/air-2-0-web-server-using-the-new-server-socket-api/
    My question is under socketDataHandler() function.
    Thanks.

  • Using event.target.submitForm to submit a PDF and XML attachment in a single email.

    I have a button on a PDF form which emails a PDF and XML attachment of the current form in two seperate emails. The code is as follows:
    event.target.submitForm({cURL:"mailto:" +  "[email protected]" +"?subject="+"Request for action " + "&body=Please find attached..." ,cSubmitAs:"XML",cCharset:"utf-8"});
    event.target.submitForm({cURL:"mailto:" +  "[email protected]" +"?subject="+"Request for action " + "&body=Please find attached..." ,cSubmitAs:"PDF",cCharset:"utf-8"});
    This results in 2 seperate emails, when all I need is a single email with two attachments. Is there a way to do this?

    As far as I know you can only attach one attachment at once.

  • Attached corresponding image in mouse without using event.target.name in actionscript 3

    Hi,
    AS3:
    How to get general id (or) name from xml loaded images. bcoz, i want to drag and drop that images in generic method. Now, i currently used the event.target.name for each one.
    So, code length was too large. See my code below.
    /*********loading images through xml********/
    var bg_container_mc:MovieClip
    var bg_bg_myXMLLoader:URLLoader = new URLLoader();
    bg_bg_myXMLLoader.load(new URLRequest("xml/backgroundimages.xml"));
    bg_bg_myXMLLoader.addEventListener(Event.COMPLETE, processXML_bg);
    function processXML_bg(e:Event):void {
              var bg_myXML:XML=new XML(e.target.data);
              columns_bg=bg_myXML.@COLUMNS;
              bg_my_x=bg_myXML.@XPOSITION;
              bg_my_y=bg_myXML.@YPOSITION;
              bg_my_thumb_width=bg_myXML.@WIDTH;
              bg_my_thumb_height=bg_myXML.@HEIGHT;
              bg_my_images=bg_myXML.IMAGE;
              bg_my_total=bg_my_images.length();
              bg_container_mc = new MovieClip();
              bg_container_mc.x=bg_my_x;
              bg_container_mc.y=bg_my_y;
              ContentHead.addChild(bg_container_mc);
              for (var i:Number = 0; i < bg_my_total; i++) {
                       var bg_thumb_url=bg_my_images[i].@THUMB;
                        var bg_thumb_loader = new Loader();
                       bg_thumb_loader.load(new URLRequest(bg_thumb_url));
                       bg_thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded_bg);
                       bg_thumb_loader.name="bg_load"+i;
                       bg_thumb_loader.addEventListener(MouseEvent.MOUSE_DOWN, bg_down)
                       bg_thumb_loader.x = (bg_my_thumb_width-18)*bg_x_counter;
                       bg_thumb_loader.y = (bg_my_thumb_height-45)*bg_y_counter;
                       if (bg_x_counter+1<columns_bg) {
                                 bg_x_counter++;
                       } else {
                                 bg_x_counter=0;
                                 bg_y_counter++;
    function thumbLoaded_bg(e:Event):void {
              var my_thumb_bg:Loader=Loader(e.target.loader);
             var sprite:Sprite = new Sprite();
              var shape:Shape = new Shape();
              shape.graphics.lineStyle(1, 0x0098FF);
              shape.graphics.drawRect(e.target.loader.x-2, e.target.loader.y-2, e.target.loader.width+4, e.target.loader.height+4);
              sprite.addChild(shape);
              sprite.addChild(my_thumb_bg);
              sprite.x=4;
              bg_container_mc.addChild(sprite);
              my_thumb_bg.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded_bg);
    //  get name for each image. 
    I want to change this code in generic method. do needful.
    function bg_down(event:MouseEvent):void {
              var bg_name:String=new String(event.currentTarget.name);
              var bg_load:MovieClip=event.currentTarget as MovieClip;
              if (event.currentTarget.name=="bg_load0") {
                      var alaska_mc:alaska_png=new alaska_png();
                       addChild(alaska_mc);
                       alaska_mc.x=stage.mouseX;
                       alaska_mc.y=stage.mouseY;
                       alaska_mc.name="alaska_duplicate"+alaska_inc;
                       alaska_inc++;
                       alaska_mc.startDrag(false);
                      alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
                       alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load1") {
                       var lake_mc:lake_png=new lake_png();
                       addChild(lake_mc);
                       lake_mc.x=lake_mc.mouseX;
                       lake_mc.y=lake_mc.mouseY;
                       lake_mc.name="lake_duplicate"+lake_inc;
                       lake_inc++;
                       lake_mc.startDrag(false);
                       lake_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load2") {
                       var mountn_mc:mountn_png=new mountn_png();
                       addChild(mountn_mc);
                       mountn_mc.x=mountn_mc.mouseX;
                       mountn_mc.y=mountn_mc.mouseY;
                       mountn_mc.name="mountn_duplicate"+mountn_inc;
                       mountn_inc++;
                       mountn_mc.startDrag(false);
                       mountn_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load3") {
                       var town_mc:town_png=new town_png();
                       addChild(town_mc);
                       town_mc.x=town_mc.mouseX;
                       town_mc.y=town_mc.mouseY;
                       town_mc.name="town_duplicate"+town_inc;
                       town_inc++;
                       town_mc.startDrag(false);
                       town_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load4") {
                       var water_mc:water_png=new water_png();
                       addChild(water_mc);
                       water_mc.x=water_mc.mouseX;
                       water_mc.y=water_mc.mouseY;
                       water_mc.name="water_duplicate"+water_inc;
                       water_inc++;
                       water_mc.startDrag(false);
                      water_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load5") {
                       var city_mc:city_png=new city_png();
                       addChild(city_mc);
                       city_mc.x=city_mc.mouseX;
                       city_mc.y=city_mc.mouseY;
                       city_mc.name="city_duplicate"+city_inc;
                       city_inc++;
                       city_mc.startDrag(false);
                      city_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load6") {
                        var citywide_mc:citywide_png=new citywide_png();
                       addChild(citywide_mc);
                       citywide_mc.x=citywide_mc.mouseX;
                       citywide_mc.y=citywide_mc.mouseY;
                       citywide_mc.name="citywide_duplicate"+citywide_inc;
                       citywide_inc++;
                       citywide_mc.startDrag(false);
                      citywide_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load7") {
                       var downtown_mc:downtown_png=new downtown_png();
                       addChild(downtown_mc);
                       downtown_mc.x=downtown_mc.mouseX;
                       downtown_mc.y=downtown_mc.mouseY;
                       downtown_mc.name="downtown_duplicate"+downtown_inc;
                       downtown_inc++;
                       downtown_mc.startDrag(false);
                      downtown_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load8") {
                       var powerlines_mc:powerlines_png=new powerlines_png();
                       addChild(powerlines_mc);
                       powerlines_mc.x=powerlines_mc.mouseX;
                       powerlines_mc.y=powerlines_mc.mouseY;
                       powerlines_mc.name="powerlines_duplicate"+powerlines_inc;
                       powerlines_inc++;
                       powerlines_mc.startDrag(false);
                      powerlines_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load9") {
                       var tropical_mc:tropical_png=new tropical_png();
                       addChild(tropical_mc);
                       tropical_mc.x=tropical_mc.mouseX;
                       tropical_mc.y=tropical_mc.mouseY;
                       tropical_mc.name="tropical_duplicate"+tropical_inc;
                       tropical_inc++;
                       tropical_mc.startDrag(false);
                      tropical_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load10") {
                       var waters_mc:waters_png=new waters_png();
                       addChild(waters_mc);
                       waters_mc.x=waters_mc.mouseX;
                       waters_mc.y=waters_mc.mouseY;
                       waters_mc.name="waters_duplicate"+waterthumb_inc;
                       waterthumb_inc++;
                       waters_mc.startDrag(false);
                      waters_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
    Please suggest me if any  one.
    Regards,
    Viji. S

    for each loader created, create a movieclip and add your loader to the movieclip.  assign all the properties you want to retrieve later to the movieclip and assign your event listeners to the movieclip.

  • AS 3.0 event target problem!!!

    I have an interesting problem regarding event.target in Flex
    2/ActionScript 3.0. I am using the Flex Grocer app in order to try
    something out. I am attaching listeners to all the click events and
    then printing out event.target to keep track of my events and where
    we clicked, nothing revolutionary here very easy stuff. Once I get
    the paths I would like to run code that will execute my steps and
    play the clicks back based on the event.target information that I
    got and I was able to do that except when we have popups. Here is
    the problem:
    When I execute a click on a button with event.target =
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    A poupup appears and then I click on the close button on that
    popup with event.target=
    ConfirmScreen464.UIComponent494.Button498
    COUPLE OF PROBLEMS HERE:
    1) I don’t have the path to the root (DataEntry0) even
    though I use the standard event.target.
    2) This is even a bigger problem, the DOM path
    (ConfirmScreen464.UIComponent494.Button498) is dynamically
    generated (the numbers are dynamically generated) so when I use
    that path that I got during the time I was monitoring the app, when
    I use my code to play the events that very same target does not
    correspond to the popup that the fist event caused.
    I tried using IDs but in Flex I have not found anything like
    document.getElementById() that is available in JavaScript. Any help
    on this will be greatly appreciated.
    Thanks
    p.s. I looked at the automation library that Flex has (and
    Mercury QTP uses) but that will not work for me.

    zoran,
    Sorry,I didn't explain what to do very clearly :).
    Básically, the event.taget parameter is set when you use the
    dispatchEvent function, so if you want an event to be dispatched
    from a Object you must call the dispatchEvent from this function.
    The line I gave you wont work by itself since I don't know
    how you reference
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    in your application.
    But what you need to do is call the dispatchEvent function in
    the Button104 object with the specific event you want to trigger.

  • How to check event.target type in "if" statement

    Hi, i have "roll over" event listener and i would like to that works only with MovieClips (without textfields etc.). I would like to write something like that:
    if(event.target == MovieClip){ do something }
    else { do something else}
    This doesn`t work properly.
    How to check type of event.target in "if" statement?
    Thanks for any help.


    if(getQualifiedClassName(event.target) == "flash.display::MovieClip"){ do something }
    else { do something else}
     .

  • [svn:fx-3.x] 9658: Handle complete events where event. target is not of type LoaderInfo.

    Revision: 9658
    Author:   [email protected]
    Date:     2009-08-26 12:53:16 -0700 (Wed, 26 Aug 2009)
    Log Message:
    Handle complete events where event.target is not of type LoaderInfo.
    QE notes: None.
    Doc notes: None.
    Bugs: SDK-22710
    Reviewer: Alex
    Tests run: checkintests
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22710
    Modified Paths:
        flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/core/FlexModuleFactory.as
        flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/preloaders/Preloader.as

    Anyone able to help?

  • Passing event target name to text field

    Hi There,
    I'm new to 3.0 and can use some help here... should be an
    easy one for you experts...
    I just need to pass an event target name to a text field:
    square.addEventListener(MouseEvent.MOUSE_DOWN,downObj);
    function downObj(event:MouseEvent){
    targetObj = event.target;
    mydrag.visible = true;
    targetObj.startDrag();
    mydrag.addEventListener(Event.ENTER_FRAME, dragClip);
    target_txt.text = String(event.target);
    I've also tried:
    target_txt.text = event.target;
    but no luck so far..
    Any help would be highly appreciated.
    Cheers...
    Bruno Aun
    Flash + Coldfusion Developer
    http://www.BrunoAun.com

    That's right...
    target_txt.text = String(event.target
    .name);
    works like a charm.
    thank you!

  • Compile error for DragManager.acceptDragDrop(event.target)

    This line
    DragManager.acceptDragDrop(event.target);
    seems to be giving me the following compile error:
    Implicit coercion of a value with static type Object to a
    possibly unrelated type mx.core:IUIComponent.
    (There is an arrow pointing to "target", I guess indicating
    that that is the Object causing the problem.)
    I'm not sure why this is giving me an error since the
    official Adobe document describing how to migrate applications from
    Flex 1.5 to Flex 2 says that
    DragManager.acceptDragDrop(event.target) is what's supposed to
    replace event.handled=true.

    Hi.
    The problem is that DragManager.acceptDragDrop expects a
    UIComponent but Event.target is typed as Object. You need to cast
    the target as a UIComponent. Try this:
    DragManager.acceptDragDrop(UIComponent(event.target));

  • "event.target as Socket" in Javascript

    I found an example of a small webserver built with Flex in Air. I am wanting to convert this into HTML/Javascript and all has gone well except I cannot figure out how to port this line
    var socket:Socket = event.target as Socket;
    Any suggestions?
    "var socket = event.target;" doesn't seem to work.
    Thanks,
    Kyle

    Here is the site: http://coenraets.org/blog/2009/12/air-2-0-web-server-using-the-new-server-socket-api/
    My question is under socketDataHandler() function.
    Thanks.

  • Event.Target issue

    Hi, I think I wrote this wrong but can't find a solution.
    This works:
    Parts1_mc.addEventListener(MouseEvent.CLICK, RunTraining);
    function RunTraining(e:MouseEvent):void
    Global.run = Parts1_mc.Parts1.text;
    trace(Global.run);
    When I do this, I get a undefined error message:
    Parts1_mc.addEventListener(MouseEvent.CLICK, RunTraining);
    function RunTraining(e:MouseEvent):void
    Global.run = Parts1_mc.event.target.text;
    trace(Global.run);

    Simpler is a relative thing, so I may miss since my understanding of this is also simple (more of an acceptance than an understanding)... greater minds might prevail here with a better explanation (or possibly a more confusing one).
    From what you just quoted, the simplest way of stating part of it was just as it is stated...
         “currentTarget” is the Movieclip (object) that you applied the listener to.
    So if you assigned the listener to Parts1_mc, the currentTarget of the event is Parts1_mc.  That will not vary.
    But Parts1_mc contains other objects, in your case a textfield, which is an interactive object and if interacted with will trigger the event.  Since it is a child of Parts1_mc it still gets detected by the listener that is assigned to Parts1_mc.
    You should go thru the explanation you linked and try to see how different elements can end up being the target under different conditions.  That same link is where I was going to point you to to explain things.
    Another thing you could do is just create a simple movieclip object (named container below) that contains various different types of objects.... a button, a movieclip, a dynamic textfield, a static textfield, a raw shape... and use the code below to see what comes up each time as far as currentTarget and target go...
    container.addEventListener(MouseEvent.CLICK, showTargets);
    function showTargets(evt:MouseEvent):void {
        trace(evt.currentTarget.name);
        trace("     "+evt.target.name);
    Sometimes you will see they both identify the same object (the container), but other times the target will be different.
    The "target" property of the event can end up being helpful in different scenarios, such as if you have a drop down menu.  You can assign the listeners to the parent movieclip to make coding the rollover/rollout functionality a quick couple of lines, and then use the target to determine which button within was clicked.  Beats the hoops one usually jumps thru when making a drop down menu in AS2.
    If the intention is to manipulate the object that has the listener assigned, then using currentTarget will always point you there.

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

    Hi,
    I hope everyone is doing great.
    I belong to Actionscript background and just started on Flash CC HTML-5 canvas.
    How to get event.target or event.currentTarget in Flash CC for HTML-5 canvas for click event.
    Like we used to do it in AS 3.0
    btn.addEventListener(MouseEvent.CLICK , go);
    function go(evt:MouseEvent){
       trace(" evt - "+evt.currentTarget); // It will let us know the clicked target
    For  HTML-5
    btn.addEventListener('click' , go.bind(this));
    function go(evt){
       console.log(" evt - "+evt.????t); // what is the correct syntax here?
    Thanks,

    Hey guys found the answer from stackoverflow
    it is - evt.target

  • Event.target confusion?

    I'm trying to reusing function by using event.target, but after searching and trying different method online, I found the hardest part to understand is event.target part...
    can anyone please explain to me what is the difference between(the example on right showing where I encounter those code):
    1.event.target
    2.event.target.name
    3.event.currentTarget                             //e.g. event.currentTarget.addChild(myMc);
    4.event.currentTarget.name                    //e.g. var newswf:URLRequest= new URLRequest( event.target.name +".swf");
    5. MovieClip(event.currentTarget)            //e.g. addChild(MovieClip(event.currentTarget));

    I believe that Circle is extending MovieClip so it is MovieClip. The circle is many things, you just have to say the compiler which one you mean
    This is the inheritance of MovieClip:
    MovieClip  Sprite DisplayObjectContainer InteractiveObject DisplayObject EventDispatcher Object
    The main culprit is the event.currentTarget property, which returns the safest option, Object. But it doesn't mean the circle becames only Object and nothing more, it means that the circle is just treated as just-an-object until you explicitly say "treat it as a MovieClip" by casting it as MovieClip: MovieClip(event.currentTarget).

Maybe you are looking for

  • Design patterns for updating a fact table

    I have a fact table and about 10 dimensions. One of these dimensions can be missing values, so the fact table row will link to an UNKNOWN value. When the correct value is finally entered in the dimension table i want to update any associated fact row

  • Universal Access System Pref disappeared

    Recent MBP, OS X 10.7.4.  Up until today, Universal Access worked perfectly (Command-option-+/_ to zoom screen).  Today, when I tried it, it didn't work.  When I opend System Preferences, Universal Access System Pref had disappeard.  I tried moving t

  • Batch session in sm35

    Hi gurus , I am not getting any batch session when I am running ff67. In sm35 i am not getting related batch session. Please Guide. Thanks

  • ITunes 12.0.1 does not pop up

    iTunes 12.0.1 does not pop up after I press the icon after installation. I am using OS X10.10. Any idea?

  • [svn:fx-trunk] 10230: Fix for ASDoc not handling img tag correctly

    Revision: 10230 Author:   [email protected] Date:     2009-09-14 08:54:44 -0700 (Mon, 14 Sep 2009) Log Message: Fix for ASDoc not handling tag correctly QE notes: None. Doc notes: None Bugs: SDK-22902 Tests run: checkintests Is noteworthy for integra