Addeventlistener via button click ?

Hello, is it possible to add an eventlistener via a button click ?
eg.
<mx:Button  click="myObejct.addEventListener(MouseEvent.CLICK, myFunction(event))"/>
This does not work for me, but I think it should be possible with a bit of fine-tuning ?
thanks for any help.

Yes you can
<mx:Button  click="myObejct.addEventListener(MouseEvent.CLICK, myFunction)"

Similar Messages

  • Submit PDF via Button Click into Email

    event.target.submitForm({cURL:"mailto:[email protected]" + "?subject=" + subjectext + "&body=" + bodytext + "&cc=" + ccemail address ,cSubmitAs:"PDF",cCharset:"utf-8"});
    cURL:"mailto:"
    can also write cURL:"mailto:" + variable   (i.e.= field containing email address)
    "?subject" = not sure what this means. Seems to be some sort of signal the subject is coming next
    subjectext = variable containing text you want for the subject of the email
    "&body" = not sure what this means. Seems to be some sort of signal the body text is coming next.
    subjectext = variable containing text you want for the body of the email i.e. var bodytext = "\n" + "\n" + "Thank you for........"
    "&cc=" not sure what this means. Seems to be some sort of signal the carbon copy email address is coming next.
    ccemail address = variable containing email address you want to send the email to as a cc
    cSubmitAs:"PDF" = option to send as differing formats
    cCharset:"utf-8" = unsure
    From the Book:
    Creating Dynamic Forms with Adobe® LiveCycle® Designer
    For this to work, one of the following must be true:
    Your form fillers must have Acrobat.
    Your form must be Reader extended.
    // put the code in the click event of a regular button var mail; var address = email.rawValue; //email is a text field var sub = subject.rawValue;  mail = "mailto: " + address + "?subject=" + sub; event.target.submitForm({ cURL: mail, bEmpty: true, cSubmitAs: "PDF", cCharset: "utf-8" });
    The submitForm function takes the following four parameters.
    The email address and subject
    A Boolean true to imply that all fields are posted
    The attachment file format (XML, XDP, or PDF)
    The character encoding
    Hope this helps the next person searching for this info.

    Thank you.  I finally got it to work!
    Sarah T. Love
    Grants & Contracts Director
    California Pacific Medical Center Research Institute
    475 Brannan Street, Suite 220
    San Francisco, CA   94107
    415-601-2555 cell phone
    415-600-1702 phone
    415-600-1681 fax
    Website:  http://www.cpmc.org/professionals/research/grants/index.html

  • Submitting form via button click

    Hi, i have a following code and it doesnt work and i dont know why
    <jsp:useBean id="pageinfo" class="zrna.PageInfo" scope="session"/>
    <jsp:setProperty name="pageinfo" property="*"/>
    <html>
    <head>
    <script type="text/javascript">
         function clickEvent(form,md,wrkOn)
              form.mode.value = md;
              form.workingOn.value = wrkOn;
              form.submit();
         function m(form){return true;}
    </script>     
    </head>
    <form action="index.jsp" method=get >
         <input type="hidden" name="mode" value="">
         <input type="hidden" name="workingOn" value="">
         <input type="submit" value="Add" onclick="clickEvent(this.form,'add','Student')">
         <input type="submit" value="Alter" onclick="clickEvent(this.form,'alter','Student')">
         <input type="submit" value="Done" onclick="clickEvent(this.form,'general','')">
    </form>          
    So im trying to change jsp bean properties of pageinfo thru submiting form and it doesnt work. when button is clicked the page goes blank. What am i missing?

    is this page you posted "index.jsp"?
    Not sure offhand, but could the form submit before onclick fires? If so, change them to button types, not submit types.
    The bean has those named fields? Public get/set methods?
    Does useBean have to be this?
    <jsp:useBean id="pageinfo" class="zrna.PageInfo" scope="session">
    <jsp:setProperty name="pageinfo" property="*"/>
    </jsp:useBean>

  • WDURLGenerator + link to URL via Button

    hi,
    i was searching this forum about the possibilities of the  WDURLGenerator.
    I need to link to a webpage via Button-Click.
    I set up an Button and corresponding action. In this action I simply want to call an URL (nice would also be a new window.
    Now I set up:
    WDURLGenerator.getWebResourceURL("http://www.<url>.de")
    do i have to also set up something like: wdThis.wdFirePlugUrl(url) ???
    thanx for help,
    matthias

    Matthias,
    No offence, here but:
    On the main WD forum screen just type your question in search box:
    open AND window AND url
    All the rest left as default.
    The very first hit!
    VS

  • Trying to simulate button click via ActionScript

    Hello,
    I've got code written to tell if a user is hitting his/her
    left or right arrow keys. I currently have a "next" button named
    realNext, and a "back" button named realBack. Both buttons have
    lots of code written in their on(release) functions. How can I
    utilize ActionScript to simulate a button click?
    Here's my code thus far:

    I have never had success **** this by calling the onRelease
    or onPress event functions. So to get around this I define other
    functions that do all of the work and then just use the onRelease
    and onPress event functions as callers.
    For example.
    button1.onRelease = myFunction;
    function myfunction():Void {
    // code goes here
    Now with this I can either press the button to ge thte code
    executed or I can "simulate" the button being pushed by just
    calling myFunction().
    Tim

  • Need help placing tracking script on button click

    Howdy.
    We're trying to track the button clicks on a landing page we're producing. I've got the "landing page" script in the header via the page properties but now I need to put script on a button that fires when the person clicks the button. Any help would be greatly appreciated!
    website: maysweb.tamu.edu/open-enrollment
    script:
    <script type='text/javascript'>
    // Conversion Name: Finance & Accounting - Non-Finance Managers button
    var ebRand = Math.random()+'';
    ebRand = ebRand * 1000000;
    //<![CDATA[
    document.write('<scr'+'ipt src="HTTP://bs.serving-sys.com/Serving/ActivityServer.bs?cn=as&ActivityID=1&rnd=' + ebRand + '"></scr' + 'ipt>');
    //]]>
    </script>
    <noscript>
    <img width="1" height="1" style="border:0" src="HTTP://bs.serving-sys.com/Serving/ActivityServer.bs?cn=as&ActivityID=1&ns=1"/>
    </noscript>

    Anyone got any ideas on this?

  • Link to xml from xml ( mx:Button click="function({...});" )

    links.xml contains links for page1, page2
    links.xml
    |
    +-- page1.xml
    |
    +-- page2.xml
    I try:
    <mx:Button click="loadXML2({ getField( XML(
    linksItems.currentItem ), how1Link ) });" label="Link" />
    Debugger says:
    Error: Repeater is not executing.
    at mx.core::Repeater/get currentItem()
    at LinkFromXML2/___LinkButton1_click()
    <!-- File: links.xml -->
    <?xml version="1.0" encoding="UTF-8"?>
    <rdf:RDF xmlns="
    http://web.resource.org/cc/"
    xmlns:dc="
    http://purl.org/dc/elements/1.1/"
    xmlns:rdf="
    http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <item>
    <dc:title>Page 1</dc:title>
    <dc:link>page1.xml</dc:link>
    </item>
    <item>
    <dc:title>Page 2</dc:title>
    <dc:link>page2.xml</dc:link>
    </item>
    </rdf:RDF>
    <!-- File: page1.xml -->
    <?xml version="1.0" encoding="UTF-8"?>
    <rdf:RDF xmlns="
    http://web.resource.org/cc/"
    xmlns:dc="
    http://purl.org/dc/elements/1.1/"
    xmlns:rdf="
    http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <dc:Work>
    <dc:title>Page 1</dc:title>
    </dc:Work>
    </rdf:RDF>
    <!-- File: page2.xml -->
    <?xml version="1.0" encoding="UTF-8"?>
    <rdf:RDF xmlns="
    http://web.resource.org/cc/"
    xmlns:dc="
    http://purl.org/dc/elements/1.1/"
    xmlns:rdf="
    http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <dc:Work>
    <dc:title>Page 2</dc:title>
    </dc:Work>
    </rdf:RDF>
    <!-- File: LinkFromXML.mxml -->
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="loadXML('links.xml');">
    <mx:Script>
    <![CDATA[
    import mx.collections.XMLListCollection;
    public var pathxml:String;
    public var pathxml2:String;
    private var how:Namespace = new Namespace("
    http://web.resource.org/cc/");
    private var dc:Namespace = new Namespace("
    http://purl.org/dc/elements/1.1/");
    [Bindable]
    private var how1Title:QName = new QName(dc, "title");
    [Bindable]
    private var how1Link:QName = new QName(dc, "link");
    [Bindable]
    private var how2Title:QName = new QName(dc, "title");
    [Bindable]
    private var how1externalXML:XMLListCollection;
    [Bindable]
    private var how2externalXML:XMLListCollection;
    private function loadXML(pathxml):void {
    trace (pathxml);
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest(pathxml);
    loader.load(request);
    loader.addEventListener(Event.COMPLETE, onComplete);
    private function loadXML2(pathxml2):void {
    var loader2:URLLoader = new URLLoader();
    var request2:URLRequest = new URLRequest(pathxml2);
    loader2.load(request2);
    loader2.addEventListener(Event.COMPLETE, onComplete2);
    private function onComplete(event:Event):void {
    var loader:URLLoader = URLLoader(event.target);
    var how1Items:QName = new QName(how, "item");
    var dataXML:XML = XML( loader.data );
    dataXML.addNamespace( dc );
    var how1base:XMLList = dataXML.descendants( how1Items
    how1externalXML = new XMLListCollection( how1base );
    private function onComplete2(event:Event):void {
    var loader2:URLLoader =
    URLLoader(event.target);
    var how2Items:QName = new QName(dc, "Work");
    var dataXML:XML = XML( loader2.data );
    dataXML.addNamespace( dc );
    var how2base:XMLList = dataXML.descendants( how2Items
    how2externalXML = new XMLListCollection( how2base );
    private function getField( itemXML:XML,
    field:QName):String {
    return itemXML.descendants( field ).toString();
    ]]>
    </mx:Script>
    <mx:Canvas id="HowView" backgroundColor="#FFFFCC"
    label="How"
    width="100%" height="100%">
    <mx:HBox width="100%" height="100%">
    <mx:VDividedBox width="400" height="100%" id="how1Box"
    backgroundColor="#B9C5A0">
    <mx:Repeater width="80%" id="linksItems"
    dataProvider="{ how1externalXML }">
    <mx:VBox width="80%" horizontalAlign="center"
    creationCompleteEffect="Fade">
    <mx:LinkButton click="loadXML2('{getField( XML(
    linksItems.currentItem ), how1Link )}')" label="{ getField( XML(
    linksItems.currentItem ), how1Title) }" />
    </mx:VBox>
    </mx:Repeater>
    </mx:VDividedBox>
    <mx:VDividedBox width="100%" height="100%" id="how2Box"
    backgroundColor="#6BA1A3">
    <mx:Repeater width="100%" id="workItems"
    dataProvider="{ how2externalXML }">
    <mx:VBox width="534" horizontalAlign="center"
    creationCompleteEffect="Fade">
    <mx:Label text="{ getField( XML(
    workItems.currentItem ), how2Title) }" color="#000000"/>
    </mx:VBox>
    </mx:Repeater>
    </mx:VDividedBox>
    </mx:HBox>
    </mx:Canvas>
    </mx:Application>

    "Cole_62" <[email protected]> wrote in
    message
    news:gd2q5r$f08$[email protected]..
    > no i dont think this will work because i need to iterate
    through each
    > <item> in
    > the XML...below is an exmaple of possible tree structure
    of the XML:
    > channel
    > -->item1
    > ----->title
    > ----->imgs
    > --------->imgUrl
    > --------->imgUrl
    > -->item2
    > ----->title
    > ----->imgs
    > ---------->imgUrl
    > -->item3
    > ------>title
    > ------>imgs
    > ----------->(no imgs)
    >
    > i thought to handle this using something like the
    ATTACHED CODE below:
    >
    > ...i need to be able to go through each <item> and
    <imgUrl> (because i
    > dont
    > know how many (if any) there are!) sorry if my PHP
    background shines
    > through!
    >
    > THANKS!
    >
    > <mx:Repeater id="feed"
    dataProvider="{XML.channel.item}">
    > <mx:HBox>
    > <mx:Text text="{feed.currentItem.title}"/>
    > <mx:Repeater id="item"
    dataProvider="{feed.currentItem.imgs}">
    > <!-- PSEUDO CODE I NEED HELP RESOLVING:
    > if ("{item.currentItem.imgURL}")
    > -->
    > <mx:Image source="{item.currentItem.imgUrl}"/>
    > </mx:Repeater>
    > </mx:HBox>
    > </mx:Repeater>
    How bout
    <mx:Repeater id="feed"
    dataProvider="{XML.channel.item}">
    <mx:HBox>
    <mx:Text text="{feed.currentItem.title}"/>
    <mx:Repeater id="item"
    dataProvider="{feed.currentItem.imgs}">
    <mx:Image
    source="{item.currentItem.imgURL.length()>0?item.currentItem.imgURL:null}"
    includeInLayout="{item.currentItem.imgURL.length()>0}"/>
    </mx:Repeater>
    </mx:HBox>
    </mx:Repeater>

  • Control two functions on one button click

    Hello,
    first off, I am relatively new to actionscript 3.0. I was
    wondering if anyone knows how I can control two events on one (the
    same) button click. On click, the first function must jump the user
    to a particular frame label and at the same time trigger a second
    function which is a movie clip on that particular frame. I must
    note that the event listener is attached to an actual Button and
    not a movie clip.
    Any help would be greatly appreciated.

    Thanks for the quick response. I tried out your solution but
    I get the following error...
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at index_fla::MainTimeline/rev()
    at index_fla::MainTimeline/resources()
    I also tried to create another event listener on Mouse_UP
    ex:
    topNav1_btn.addEventListener(MouseEvent.CLICK, resources);
    topNav1_btn.addEventListener(MouseEvent.MOUSE_UP, rev);
    but I get another strange error...
    ## [Tweener] Error: [object MovieClip] raised an error while
    executing the 'onComplete'handler.
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at MethodInfo-218()
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at caurina.transitions::Tweener$/updateTweenByIndex()
    at caurina.transitions::Tweener$/updateTweens()
    at caurina.transitions::Tweener$/onEnterFrame()
    ## [Tweener] Error: [object MovieClip] raised an error while
    executing the 'onComplete'handler.
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at MethodInfo-241()
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at caurina.transitions::Tweener$/updateTweenByIndex()
    at caurina.transitions::Tweener$/updateTweens()
    at caurina.transitions::Tweener$/onEnterFrame()
    any other thoughts? Thanks in advance.

  • Set Category for multiple IR's via Button in Taskbar

    Hi!
    I have been searching the net for this for some time now, but wasn't successful, so maybe here is somebody who could help me. Hope I did select the correct forum for this thread...
    In SCSM 2012 - is it possible to set the category for multiple IRs in one step via button in the taskbar, same like being able to assign multiple IRs to Analysts or change Status via button in taskbar, without need to open each IR and set it in there?
    Any hint would really be appreciated :-)

    Yes it's possible, but I'm unaware of any solution out there that you can just plug&play. (Somebody might know of one, though!)
    If you're a developer (or know a developer), then you can create a custom console task in Visual Studio, bundle it with a management pack, and import that management pack.
    From a high level, first you'll need to create a custom console task. The following blog posts give some insight into how to create one.
    http://blogs.technet.com/b/servicemanager/archive/2010/02/11/tasks-part-1-tasks-overview.aspx
    http://blogs.technet.com/b/servicemanager/archive/2010/12/22/tasks-part-2-custom-console-tasks-for-create-edit-delete.aspx
    (note: The second post also discusses sealing and bundling management packs.)
    To solve your specific request, the console task code will (again, at a high level) present a window for the user to choose a classification category. Then, after clicking apply on that window, the console task code will iterate through all of the "nodes"
    sent as a parameter to the console task. A "node" represents an incident selected by the user in the incident view. For each incident in the list, set the classification category to whatever value the user selected, then apply the changes to
    that incident.
    If you want to take a crack at building this solution yourself and this is your first custom extension for Service Manager, let me know, I'll help you through the gritty details :)
    And, like I said, if someone knows of a solution you can just import, that'll make things a heck of a lot easier ;)

  • Way to search custom engines via right-click/updated version of AcidSearch?

    Are there any current ways to search highlighted text in a customized list of engines via right-clicking it? I used to do it via AcidSearch but it hasn't been updated in years, and the author is not planning on doing so.
    I'm currently using Firefox because it has that capability via add-ons, but I'd rather use Safari as I've noticed that version 4 can handle most pages FF can't, plus it's faster and FF 4 has been postponed to 2011. Thanks
    P.S. I have a list of custom engines in the search bar via Glims but that's not what I'm asking about.

    Hi Mark,
    I think this application has a some potential. However, it has a long way to go to reach that potential.
    Let's start with the toolbar (the blue button that appears on the taskbar) that is created by default when the application is installed. If you'll forgive my bluntness, it's a distracting waste of space and a flagrant misuse of the toolbar user interface.
    If there is something wrong that requires urgent attention (like, for example, the hard disk is failing), then the program should open a dialog box. Otherwise, user notifications should be displayed in -- surprise -- the Notification Area. Please have your developers read and understand the Windows User Experience Interaction Guidelines. 
    And seriously, what is up with the Coverflow-esque marketing garbage on the -- ugh -- "Ultimate Business Tool" tab? If you're wondering why this program has the reputation of being bloatware, look no further than here. This has no business being in a diagnostic application.
    I could say more, but I think you get my drift. Remember the old version of PC Doctor? When all it did was scan your computer for problems and gave you a nice report, without trying to take over your taskbar or sell you stuff? Ah, the good old days.

  • How to call web service on a button click in Web UI

    Hi Experts,
    I have a requirement to call/consume external web service on a button click in CRM web UI. Can someone help me with the code sample for invoking web service from crm web ui?
    Thanks in advance.
    Cheers,
    Sumit Mittal

    Consuming external web service directly without xi system in between.
    u2022     SE80
    u2022     Create Enterprise Service-> Choose object type as u201CService Consumeru201D
    u2022     Select URL HTTP destination in the next step
    u2022     Give the WSDL url in the url point
    u2022     Give any package name or store it in the local object.
    u2022     Corresponding proxies and data types will be generated inside the enterprise service tag
    Code sample for invoking the service via report.
    u2022     Create an object of the client proxy type here itu2019s io_clientproxy.
    u2022     Declare input and output parameters as per the structure of the service input/output parameters.
    u2022     Fill in input parameters what your service expect and call the object methods for relevant task.
    REPORT  ZWEBSERVICE_CREATNUPDATE.
    DATA: io_clientproxy TYPE REF TO zzco_user_data_service .
    DATA: output_crnup TYPE zzcreate_or_update_user_data1,
          input_crnup TYPE zzcreate_or_update_user_data_1.
    DATA :
           ls_param_crnup_in TYPE zzcreate_or_update_user_data, " CU input
           ls_param_crnup TYPE zzcreate_or_update_user_data_r, "CU Response
           ls_return_crnup  TYPE zzcrm_user, " CU Response
           ls_arg0 TYPE zzcrm_user.
    ls_arg0-first_name = 'shashank'.
    ls_arg0-last_name = 'testw/ouserid'.
    ls_arg0-org_name = 'Test_Org'.
    "ls_arg0-USER_ID = '369713'.
    ls_param_crnup_in-arg0 = ls_arg0.
    input_crnup-parameters = ls_param_crnup_in.
    TRY.
        CREATE OBJECT io_clientproxy
          EXPORTING
            logical_port_name = 'LP4'.
      CATCH cx_ai_system_fault .
    ENDTRY.
    TRY.
        CALL METHOD io_clientproxy->create_or_update_user_data
          EXPORTING
            input  = input_crnup
          IMPORTING
            output = output_crnup.
      CATCH cx_ai_system_fault .
      CATCH cx_ai_application_fault .
    ENDTRY.
    ls_param_crnup = output_crnup-parameters.
    ls_return_crnup = ls_param_crnup-return.
    IF ls_return_crnup IS INITIAL.
      WRITE : 'User creation failed'.
    ELSE.
      WRITE :  'Process Status : ',ls_return_crnup-process_status,
               /'User Id : ',ls_return_crnup-user_id,
                       /'First Name :',ls_return_crnup-first_name,
               /'Last Name :',ls_return_crnup-last_name,
               /'Org Name : ',ls_return_crnup-org_name.
    ENDIF.

  • How to diplay table row dynamically  by button click

    Hi All,
    I had a table with  with visible row count '3',   i want to display dynamic row  by a button click, mean a 4 th row need to  be added to the table with same like  row '3'.
    please help me ..
    Thanks,
    Raj.

    Hi Raju,
    while click the Add Button,
    Get the all the Rows from the Table  and Put it in to one internal table . after that append the one empty record to that internal table. then again bind to that node.
    Like following code.
      DATA lo_nd_sales TYPE REF TO if_wd_context_node.
      DATA lo_el_sales TYPE REF TO if_wd_context_element.
      DATA ls_sales TYPE wd_this->element_sales.
      DATA lt_sales TYPE wd_this->elements_sales.
    navigate from <CONTEXT> to <SALES> via lead selection
      lo_nd_sales = wd_context->get_child_node( name = wd_this->wdctx_sales ).
    get element via lead selection
      lo_el_sales = lo_nd_sales->get_element(  ).
      CALL METHOD lo_nd_sales->get_static_attributes_table
    EXPORTING
       from   = 1
       to     = 2147483647
        IMPORTING
          table  = lt_sales
      IF lt_sales IS NOT INITIAL.
        CLEAR ls_sales.
        APPEND ls_sales TO lt_sales.
        lo_nd_sales->bind_table( lt_sales ).
      ENDIF.
    Regards,
    Vijay.

  • Open LOV popup with a button click or image link click

    hi , a try the solution:
    11g: How to populate LOV from button click
    for open pòpup of lov , but don't works :
    first the others components block the submit of button
    i put the inmediate propertie but lov don't still open
    any ideas???

    Does this one help?
    Invoke lov popup window via keypress

  • I am writting a test  using a sequencer to test for multiple button click

    I'm using flex sdk 4.1 and have a situation where a  button click is sometimes called twice. I am writting a test for this using a sequencer and it will run for at least one button click, what I am not sure is how to test for multiple click events(which shouldn't happen, but occours randomly in my project)
    package tests.view
        import flash.events.MouseEvent;
        import flexunit.framework.Assert;
        import mx.events.FlexEvent;
        import org.flexunit.async.Async;
        import org.fluint.sequence.SequenceEventDispatcher;
        import org.fluint.sequence.SequenceRunner;
        import org.fluint.sequence.SequenceWaiter;
        import org.fluint.uiImpersonation.UIImpersonator;
        import views.AddComments;
        public class TestAddComments
            private var view:AddComments;
            [Before(async,ui)]
            public function setUp() : void
                view = new AddComments;
                Async.proceedOnEvent( this, view, FlexEvent.CREATION_COMPLETE, 600 );
                UIImpersonator.addChild( view );
            [Test]
            public function testButtonClick():void
                view.addCommentBtn
                var sequence:SequenceRunner = new SequenceRunner( this );
                sequence.addStep( new SequenceEventDispatcher( view.addCommentBtn, new MouseEvent( 'click', true, false ) ) );
                sequence.addStep( new SequenceWaiter( view.addCommentBtn, MouseEvent.CLICK, 100 ) );
                sequence.run();

    The only way you could test for that type of circumstance... one where something may happen... is to do so with a timeout. In other words, you cannot let the test pass simply because the first event occurred.
    Two ways to handle this... with sequences:
    Instead, you write a test that expects 2 clicks. In the assertion handler (which would only be reached if both clicks occur) you would fail the test:
    fail('i shouldnt be here');
    In the Waiter for the 2nd click, you would specify a timeout handler. That timeout handler will get called in the 2nd click does not occur in the specified time... (finding that time is the hard part). The default timeout handler fails the test, however, in your case, your timeout handler would just happily do any assertions needed and move on. A timeout does not necessarily mean failure... in your case, it is correct
    Second choice:
    You could create a timer. Create an event handler for the button click which increments a counter. Start the timer, do your test. However, have your test pending on the timer's completion rather than something like the click.. In that case, you would then be able to just check the count:
    private var clickCount:int = 0;
    [Test]
    public function testButtonClick():void {
         var timer:Timer = new Timer( 100, 1 );
        Async.handleEvent( this, timer, TimerEvent.COMPLETE, checkClickCount );
         view.addCommentBtn.addEventListener( 'click', function( e:Event ):void { clickCount++ } );
         view.addCommentBtn.dispatchEvent( new MouseEvent( 'click;, true, false ) );
    private function checkClickCount( e:Event ):void {
    assertEquals( 1, clickCount );
    However, I can't imagine how the test you are describing could ever yield more than one click event... I am guessing the problem is elsewhere, but this will help you verify
    Mike

  • Loading movie clip to stage with button click AS3

    I'm trying to figure out how to load a movie clip to the stage with a button click and have the movieclip close again using a close button. Does anyone have a step by step on how to do this or links to some tutorials.
    Below is an example of what I'm trying to do.

    Alrighty I changed the publish settings to as3. I'm still getting two errors:
    Scene 1
    1046: Type was not found or was not a compile-time constant: Popup1Btn.
    Scene 1, Layer 'as', Frame 1, Line 3
    1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
    So my setup on my main timeline is I have an actionscript layer with this code now:
    var popup1:Popup1
    Popup1Btn.addEventListener(MouseEvent.CLICK,addF);
    ClosePopup1.addEventListener(MouseEvent.CLICK,closeF);
    function addF(e:MouseEvent):void{
    popup1=new Popup1();
    addChild(popup1);
    function closeF(e:MouseEvent):void{
    removeChild(popup1);
    popup1=null;
    On the stage I have a button with the isntance/AS linkage name Popup1Btn. Inside my Popup1 MC I have a box with text and then a button with the instance/linkage name ClosePopup1 to close the popup.
    What am I missing?

Maybe you are looking for