Click event of button does not

I am a newbie to Flex. What I'm trying to do is to do a button when you click it, it displays a string. I love the code within a class, if possible. This is the code that I use. When the button is clicked, the event I put is not triggered. Any help will be appreciated.
==============================================
Y.MXML
==============================================
<? XML version = "1.0" encoding = "utf-8"? >
< mx:Application
' xmlns:MX =' http://www.adobe.com/2006/mxml '
xmlns:custom = "Y.*".
layout = "absolute".
width = "411" height = "208" >
< custom id: MyButton = "myButton" label = "xyz" x = "10" y = "10" width = "165" height = "56" / >
< / mx:Application >
==============================================
MyButton.as
==============================================
package Y
{
import flash.events.MouseEvent;
Import mx.controls.Button;
Import mx.events.FlexEvent;
Import mx.controls.Alert;

public class MyButton extends button
{
public var myButton:Button;

public void MyButton()
{
Super();

addEventListener)
FlexEvent.CREATION_COMPLETE,
creationCompleteHandler
);

MyButton = new Button();
}

private void creationCompleteHandler(event:FlexEvent):void
{
myButton.addEventListener (MouseEvent.CLICK, myClickHandler, true);
}

public void myClickHandler(event:MouseEvent):void
{
Alert.Show ("myClickHandler");
dispatchEvent (event);
}
}
}
==============================================

Found the answer to my problem.
==============================================

<>
' xmlns:MX =' http://www.adobe.com/2006/mxml '
xmlns:custom = "Y.*".
layout = "absolute".
width = "411" height = "208" >

label = "xyz".
x = "10" y = "10" width = "165" height = "56" / >

==============================================
package Y
{
import flash.events.MouseEvent;

Import mx.controls.Alert;
Import mx.controls.Button;

public class MyButton extends button
{
public void MyButton()
{
Super();

addEventListener)
MouseEvent.CLICK,
myClickHandler
);
}

public void myClickHandler(event:MouseEvent):void
{
Alert.Show ("myClickHandler");
}
}
}
==============================================

Tags: Flex

Similar Questions

  • NB100 - right click on the button does not

    Bought a new NB100 which was pre installed with XP Home SP3 - 6 weeks ago. Excellent machine for it's size although a little slow.

    Recently I used it in flight and had to shut it down before landing, and I let go to Hibernate by closing the form. When I opened the screen the next day the battery was flat, but otherwise was ok but now I find the click right no longer works. On the opening the left click login screen now does not work so I need to use CTRL-ALT-DEL twice to get into windows.

    I reinstalled the mouse driver, but that didn't fix it.

    If I plug a Microsoft USB mouse that works fine with the two clicks left and right to work, but not touchpad.

    In desperation I even rebooted the complete software system 'install system' that is on the hard drive.

    All ideas

    Looks like the touchpad can be defective, or something has come loose.

    You must send the system to a Service Center for repair. There is a list of ASP on the Toshiba site.

  • Right click on the button does not work

    I tried to use the right click button to copy and paste and delete things or get this bar you usually get when you right click, but it does not work. It works as a second main button. How should I do?

    How good are you click?
    How is it implemented  - system - Trackpad preferences?

  • Click the command button DOES not

    Hello

    I have a single command button on an UIR embedded in a dll I call TestStand. The button does nothing when you click sort, but when I press or , it works fine. Does anyone can say why this is happening?

    int CVICALLBACK TERMINATE_BUTTON (int, int int event, control panel,
    void * callbackData, int eventData1, int eventData2)
    {
    switch (event)
    {
    case EVENT_COMMIT:

    event action

    break;

    case EVENT_LEFT_CLICK:

    event action

    break;

    case EVENT_LEFT_CLICK_UP:

    event action

    break;

    }
    return 0;
    }

    Thank you in advace,

    JulianC

    Hello JulianC, a little research on the forum showed this thread that describes nearly the same situation as yours: you might find helpful advice, especially in LuisG post marked as solution and following.

  • New Notebook Laser Mouse 7000 - click on the button does not work so it is unusable

    If this is the wrong forum, please let me know. I couldn't find an obvious forum for mice. My old wireless mouse does so after much research, I chose a Laser Mouse 7000 and ordered online. I have download the drivers, follow the instructions for setting up and pressing the buttons, the installer with ALL THE BUTTONS by DEFAULT, reset and CLICK does not work. It acts like I am struck by right click. I tried moving, rearranging button settings, nothing works. When I go into control panel it says it is not working properly, but this certainly isn't. I also restarted x 2 to try to make the problem go away.

    It is a defective material, so should I just sent to the seller? That I've already lost too much time on this stupid thing. If I didn't always have a wireless mouse, I would not be able to use my PC

    Windows vista 64-bit standard

    Oh, I try the product. I have to enter the product number. It is very very small and very difficult to read, but I can enter the product correctly, I think. But here is the message that I will be back:

    "The product ID does not match the selected product.
    The product ID you entered is for Microsoft Wireless Notebook Laser Mouse 7000 (all languages), which is different from Microsoft Wireless Laser Mouse 7000 (all languages) you selected for support. Please enter the ID number of the product for Microsoft Wireless Laser Mouse 7000 (all languages) or click Select the product to select the right product. »

    WTF?

    Hello

    Microsoft Hardware Support access in the United States is 1-800-936-5700

    Dial the number and when he asks PID just say you don't know. You will need to give to the
    Tech answers so have a magnifying glass very convenient. There could be a more easy to read number on
    the receiver.

    Believe it or not, I had exactly the same experience with my entire keyboard and mouse, and I am
    in the meantime the new series arrived. Rob - bicycle - Mark Twain said it is good.

  • Trackpad and left and rick click on the button does not work since the upgrade to windows8

    I have a Sony Vaio VGN-FW21Z and I have upgraded from windows 7 to windows 8, the laptop works beautifully, but I'm forced to use a usb mouse as my pad and click left and right click doesn't work and I tried to install all the drivers several times to fix this problem and nothing's done, can someone please shed some light on this issue please.

    Hi Maiku,

    Windows 8 drivers are not available for your model. Check out the following link.
    Support for VGN-FW21Z http://www.sony.co.uk/support/en/product/VGN-FW21Z/updates

    As it is has no drivers for Windows 8 operating system, I suggest you to uninstall the current drivers for touchpad and install in compatibility mode.


    Refer to this link:
    make the programs more compatible with this version of Windows

    http://Windows.Microsoft.com/en-in/Windows-8/older-programs-compatible-version-Windows

    If the problem persists, you can contact Sony support by using the community available in the link above.

    I hope this helps.

  • Dear friends, could advise you on the activation of the lightroom? I renewed my subscription for Lightroom in July through creative cloud, but when I open it it says Hat subscription must be renewed, click on renew button does not help. Have al

    Thank you!

    Have you tried this: https://helpx.adobe.com/creative-cloud/help/sign-in-out-activate-apps.html

  • When I click on the new tab, new tab button does NOT open.

    When I click on the new tab, new tab button does NOT open.

    Please update your browser Firefox 3.6.24 or 8 and check

  • Click right button does not not on Satellite P300 - 19 p

    Hello

    Monday, I bought a Toshiba Satellite P300 - 19 p.
    And I love it! : ^ 0 *

    Only today I turn it on and my right click button does not work! :-(
    I would appreciate any help that can get the button works again before I decide to drive to the store with the cell phone.

    Thank you
    Claire

    Hello

    what you man exactly when you say that the right button does not work? What do you do with it?

    Do you mean the external mouse or button of the laptop?

    You can reinstall the mouse driver. Search for the driver on the site of Toshiba for touchpad drivers or the manufacturer s Web site form the external mouse.

  • Scanner EPSON Perfection V200 Photo: PDF button does not work since I use the scanner with an ASUS i5 running Win 7 Ultimate desktop computer.

    The PDF button does not work since I use the scanner with an ASUS i5 running Win 7 Ultimate desktop computer. I downloaded the 64-bit Epson software for the scanner.

    I found the solution to the problem, and it is indeed with the revised in Windows 7 Control Panel.

    Here how to solve the problem:
    Go to the control panel in Windows 7.
    Search scanner in the upper search box to the right
    You will see a "view scanners and cameras".
    Click it, you will see the Epson Perfection V200. Highlight.
    Click Properties, then Yes, then events.
    Where it says select an event, you MUST choose the event suitable for each option.
    To the Start button, choose Start the series of creativity
    For the copy button Choose launch Epson Scan
    E-mail button also Epson scan
    PDF includes Epson scan
    There you go.
    Now, all this was not necessary before, there are no instructions, and the fault lies with MS. how much more confused MS will do the control panel?
  • Delete the file as an attachment button does not work

    I have a form with a box the user can attach files. There are three buttons. To add a file to open the file to see it and the third button to delete the file that is highlighted in the drop-down list. Remove the button does not work. You see something wrong with my script?

    ADD A SCRIPT FILE

    MeetingMinutes.LogoControls.Attachments.Button1::click - (JavaScript, client)
    myDoc = event.target var;
    sFile var = "myFile" + NumericField1.rawValue;
    myDoc.importDataObject ({cName: sFile});
    myDataObject var = myDoc.getDataObject (sFile);

    sFileName var = myDataObject.path;

    ListBox1.addItem (sFileName, sFile);

    NumericField1.rawValue = NumericField1.rawValue + 1;

    OPEN THE SCRIPT FILE

    MeetingMinutes.LogoControls.Attachments.Button2::click - (JavaScript, client)
    try {}
    myDoc = event.target var;
    var sFile = ListBox1.rawValue;

    myDoc.exportDataObject ({cName: sFile, nLaunch: 2});
    }
    catch (e)
    {
    App.Alert ("Click on the file you want to open (select)," + "\n" + 'then click on the button to open the selected file' ");
    }

    REMOVE THE BUTTON SCRIPT

    MeetingMinutes.LogoControls.Attachments.Button3::click - (JavaScript, client)
    try {}
    myDoc = event.target var;
    var sFile = ListBox1.getDisplayItem (ListBox1.selectedIndex);

    If (sFile! == "") {}
    var nResponse = xfa.host.messageBox ("you are about to delete the attached highlighted file. \n\nDo you want to continue? ', 'delete an attachment ", 1, 2);
    If (nResponse == 4) {}
    myDoc.removeDataObject (sFile) + ListBox1.deleteItem (ListBox1.selectedIndex) + (NumericField1.rawValue = NumericField1.rawValue - 1);
    }
    } else {}
    xfa.host.messageBox ("no document selected. Click on the file to delete. ») ;
    }
    } catch (e) {}
    xfa.host.messageBox ("error in deleting of document");
    }

    Change var sFile = ListBox1.getDisplayItem (ListBox1.selectedIndex);

    TO

    var sFile = ListBox1.rawValue;

    Kyle

  • Button does not... and I don't even know why

    I have this frame 1:

    IMAGE NUMBER.

    slidenumber_txt. Text = currentFrame + "of" + totalFrames; Object (this).

    BUTTONVISBILITY / /.

    a_btn. Visible = true;

    b_btn. Visible = true;

    c_btn. Visible = true;

    d_btn. Visible = false;

    e_btn. Visible = false;

    f_btn. Visible = true;

    g_btn. Visible = true;

    i_btn. Visible = true;

    j_btn. Visible = true;

    k_btn. Visible = false;

    l_btn. Visible = false;

    h_btn1a. Visible = true;

    h_btn1a. SetStyle ("icon", iconh);

    h_btn1a.addEventListener (MouseEvent.ROLL_OVER, fh_btnro);

    function fh_btnro(e:MouseEvent):void {button_txt.text = 'Interacción' ;}

    h_btn1a.addEventListener (MouseEvent.ROLL_OUT, fbtnrout);

    h_btn1a.addEventListener (MouseEvent.CLICK, fbtnclickh1a);

    function fbtnclickh1a(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/interactions/interaction1a.swf"));

    }

    function fbtnclicki(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/documents/document1a.swf"));

    }

    function fbtnclickf(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/sounds/audioplayer1a.swf"));

    }

    function fbtnclickj(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/videos/video1a.swf"));

    }

    function fbtnclickk(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/tests/test1a.swf"));

    }

    And this on frame 2:

    slidenumber_txt. Text = currentFrame + "of" + totalFrames;

    a_btn. Visible = true;

    b_btn. Visible = true;

    c_btn. Visible = true;

    d_btn. Visible = true;

    e_btn. Visible = true;

    f_btn. Visible = true;

    g_btn. Visible = true;

    i_btn. Visible = true;

    j_btn. Visible = false;

    k_btn. Visible = false;

    l_btn. Visible = false;

    h_btn1b. Visible = true;

    h_btn1b. SetStyle ("icon", iconh);

    h_btn1b.addEventListener (MouseEvent.ROLL_OVER, fh_btnro1b);

    function fh_btnro1b(e:MouseEvent):void {button_txt.text = 'Interacción' ;}

    h_btn1b.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    Object (this),.h_btn1b.addEventListener (MouseEvent.CLICK, fbtnclickh1b);

    function fbtnclickh1b(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("lesson1/interactions/interaction1b.swf"));

    }

    I also have this on another layer:

    import flash.events.MouseEvent;

    Import fl.transitions.Tween;

    Fl.transitions.easing import. *;

    Import fl.transitions.TweenEvent;

    Stop();

    STADIUM.

    stage.displayState = StageDisplayState.FULL_SCREEN;

    CUSTOM MENU.

    var custom_menu:ContextMenu = new ContextMenu();

    custom_menu.hideBuiltInItems ();

    option1 var = new ContextMenuItem ("© Copyright 2012 Jeje Designs all rights reserved");

    var option2 = new ContextMenuItem ("+ 1 787.272.5059: ") [email protected] "); "

    Option3 var = new ContextMenuItem ("project title: presentation system 1.0 Build 1 Release 1 |") 01032012 ");

    option4 var = new ContextMenuItem ("Devigner: Edwin Merced | ") [email protected] "); "

    Option5 var = new ContextMenuItem ("security access");

    Option5. Enabled = false;

    Option5.separatorBefore = true;

    custom_menu.customItems.push (option1 option2, option3, option4, option5);

    contextMenu = custom_menu;

    NAVIGATION.

    a_btn. SetStyle ("icon", icona);

    b_btn. SetStyle ("icon", iconb);

    c_btn. SetStyle ("icon", iconc);

    d_btn. SetStyle ("icon", icond);

    e_btn. SetStyle ("icon", icon);

    f_btn. SetStyle ("icon", iconf);

    g_btn. SetStyle ("icon", ihsane);

    i_btn. SetStyle ("icon", iconi);

    j_btn. SetStyle ("icon", iconi);

    k_btn. SetStyle ("icon", iconk);

    l_btn. SetStyle ("icon", iconl);

    a_btn.addEventListener (MouseEvent.ROLL_OVER, fa_btnro, false, 0, true);

    b_btn.addEventListener (MouseEvent.ROLL_OVER, fb_btnro, false, 0, true);

    c_btn.addEventListener (MouseEvent.ROLL_OVER, fc_btnro, false, 0, true);

    d_btn.addEventListener (MouseEvent.ROLL_OVER, fd_btnro, false, 0, true);

    e_btn.addEventListener (MouseEvent.ROLL_OVER, fe_btnro, false, 0, true);

    f_btn.addEventListener (MouseEvent.ROLL_OVER, ff_btnro, false, 0, true);

    g_btn.addEventListener (MouseEvent.ROLL_OVER, fg_btnro, false, 0, true);

    i_btn.addEventListener (MouseEvent.ROLL_OVER, fi_btnro, false, 0, true);

    j_btn.addEventListener (MouseEvent.ROLL_OVER, fj_btnro, false, 0, true);

    k_btn.addEventListener (MouseEvent.ROLL_OVER, fk_btnro, false, 0, true);

    l_btn.addEventListener (MouseEvent.ROLL_OVER, fl_btnro, false, 0, true);

    a_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    b_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    c_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    d_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    e_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    f_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    g_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    i_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    j_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    k_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    l_btn.addEventListener (MouseEvent.ROLL_OUT, fbtnrout, false, 0, true);

    a_btn.addEventListener (MouseEvent.CLICK, fbtnclicka, false, 0, true);

    b_btn.addEventListener (MouseEvent.CLICK, fbtnclickb, false, 0, true);

    c_btn.addEventListener (MouseEvent.CLICK, fbtnclickc, false, 0, true);

    d_btn.addEventListener (MouseEvent.CLICK, fbtnclickd, false, 0, true);

    e_btn.addEventListener (MouseEvent.CLICK, fbtnclicke, false, 0, true);

    f_btn.addEventListener (MouseEvent.CLICK, fbtnclickf, false, 0, true);

    g_btn.addEventListener (MouseEvent.CLICK, fbtnclickg, false, 0, true);

    i_btn.addEventListener (MouseEvent.CLICK, fbtnclicki, false, 0, true);

    j_btn.addEventListener (MouseEvent.CLICK, fbtnclickj, false, 0, true);

    k_btn.addEventListener (MouseEvent.CLICK, fbtnclickk, false, 0, true);

    l_btn.addEventListener (MouseEvent.CLICK, fbtnclickl, false, 0, true);

    function fa_btnro(e:MouseEvent):void {button_txt.text = 'Salida' ;}

    function fb_btnro(e:MouseEvent):void {button_txt.text = 'Final' ;}

    function fc_btnro(e:MouseEvent):void {button_txt.text = "Siguiente" ;}

    function fd_btnro(e:MouseEvent):void {button_txt.text = "Previous" ;}

    function fe_btnro(e:MouseEvent):void {button_txt.text = 'Inicio' ;}

    function ff_btnro(e:MouseEvent):void {button_txt.text = "Audio" ;}

    function fg_btnro(e:MouseEvent):void {button_txt.text = 'Glosario' ;}

    function fi_btnro(e:MouseEvent):void {button_txt.text = "Lectura" ;}

    function fj_btnro(e:MouseEvent):void {button_txt.text = 'Vidéo' ;}

    function fk_btnro(e:MouseEvent):void {button_txt.text = "Prueba" ;}

    function fl_btnro(e:MouseEvent):void {button_txt.text = 'Button L' ;}

    function fbtnrout(e:MouseEvent):void {button_txt.text = "" ;}

    function fbtnclicka(e:MouseEvent):void {var mc:lessonexit_mc = new lessonexit_mc();}

    MC.x = 479;

    MC.y = 290;

    addChild (mc) ;}

    function fbtnclickb(e:MouseEvent):void {gotoAndStop ("lastframe") ;}

    function fbtnclickc (e:MouseEvent):void{nextFrame() ;}

    function fbtnclickd (e:MouseEvent):void{prevFrame() ;}

    function fbtnclicke(e:MouseEvent):void {gotoAndStop ("firstframe") ;}

    / * function fbtnclickf(e:MouseEvent):void {var mc:audioplayer_mc = new audioplayer_mc();}

    MC.x = 751;

    MC.y = 141;

    addChild (mc) ;} */

    function fbtnclickg(e:MouseEvent):void {}

    var loadera = new Loader();

    addChild (loadera);

    loadera. Load (new URLRequest("glossary/glossary.swf"));

    }

    function fbtnclickh(e:MouseEvent):void {}

    / * function fbtnclicki(e:MouseEvent):void {button_txt.text = 'I' ;} * /}

    / * function fbtnclickj(e:MouseEvent):void {button_txt.text = 'J' ;} * /}

    / * function fbtnclickk(e:MouseEvent):void {button_txt.text = 'K' ;} * /}

    function fbtnclickl(e:MouseEvent):void {button_txt.text = 'L' ;}

    H_btn1b button does not... I wonder why?

    First of all, try to put b on another layer and see if that fixes it.

  • iPhone 5 home button does not work after ios 10

    My 5 Iphone Home button does not work after update final IOS version of 10.

    The home button works on the first push to wake the phone but it will not open the phone the second button.

    I activated the assist button, which does not work either. But what I discover is if I open device for assistance then touch and lock screen click on the button home will work once to open the phone. If I open any app I can't close it unless I go through the same routine.

    You attempted to restart your phone?

    You can do so by holding the sleep/wake button and the Home button simultaneously until the Apple logo appears

  • My mute button does not work

    The button does not work everytime I try to put my phone on silent. I turn it down and it will automatically return to the sound, it activates again upward. What can I do?

    Hello Jackie101foever,

    Thank you for using communities Support from Apple!

    As I understand it, you can't silence your iPhone.  I have a suggestion that should help you with this.

    The first thing we want to do is to make sure that you have a current backup of everything on your iPhone.  If you follow this link, you will find instructions on how to make a backup:

    The backup of your iPhone, iPad and iPod touch

    If the silent button moves upward on its own, so you must do this checked by a service representative.  You can find the nearest one by looking here:

    Find locations

    If the button is stay down, but do not silence the iPhone then we want to restore all settings.

    Reset preference files resets all parameters that may be problems. This step will not delete your contacts, photos or personal information. It deletes all your preferences for Wi - Fi, Bluetooth, do not disturb, Notifications, general, sounds, brightness & wallpaper and privacy and removes your Touch ID & password.

    Do you this by clicking on settings > general > reset > reset all settings.

    Once you have done this, restart the iPhone and see if you are able to turn off the sound.

    Have a great day!

  • When I return from the page of google search for a link then button does not return return

    When I return from the page of google search for a link, then button does not return back. Instead, the same page refills. I need to go back click back button twice or even more. How to fix? I cheked it it another browser and there is no such behavior. It seems completele Firefox problem.

    the problem was resolved after remooving extenshion «user agent overrider»

Maybe you are looking for