Event handlers:  click in mxml tags or in AS?

Is there an advantage to putting click event handlers in AS rather than in the mxml tags?  For example
in AS
button_1.addEventListenter(MouseEvent.CLICK, someFunctionName);
or in mxml tags
<s:Button click="someHandlerName(event) />
Thanks

I will say that there is another advantage to MXML.
For instance, say that I have a static function I want to run any time you click a component and don't care about the event. I can do this in MXML:
<s:Whatever>
click="{doMyStaticMethod()}"
</s:Whatever>
In AS, I cannot do this. A click event in AS requires that I add an ActionListener and that the ActionListener be void and take an event. MXML gives a way around that if you like.

Similar Messages

  • [svn:fx-trunk] 10446: Event handlers defined in MXML can no longer be only two slashes.

    Revision: 10446
    Author:   [email protected]
    Date:     2009-09-20 19:09:35 -0700 (Sun, 20 Sep 2009)
    Log Message:
    Event handlers defined in MXML can no longer be only two slashes.
    Modified Paths:
        flex/sdk/trunk/samples/explorer/explorer.mxml
        flex/sdk/trunk/samples/ja_JP/explorer/explorer.mxml

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Custom AS3 Component / Event Definition for MXML Tag

    Custom AS3 Component / Event Definition for MXML Tag
    Exposing custom event in custom MXML tag.
    I have made an AS3 custom component named,
    'CustomListComponent'.
    Is a list type component extending UIComponent.
    When an item is clicked (selected) I generate a custom event
    named, 'selChange'
    I want the user to be able to use this tag, define a handler
    on the MXML tag.
    I tried using metadata like [Event("selChange")] in the
    component AS3 file with no luck.
    Any help / examples to expose a custom event from an AS3
    custom component to the MXML tag for the end user/developer would
    help significantly.
    Anyone? Thank you.

    Well, That did not take long.
    My mistake, Typo type.
    [Event(nane="selChange", type="flash.events.Event")]
    That is: naNe not naMe :(
    Thank you all for your time and responses.
    I WILL check my code more closely next time I post a
    question.
    P.S.: @VarioPegged : My code is big and not needed now. If
    you would like it anyway just message me. TY

  • Evaluating FXG files - possible to access elements and add event handlers?

    I would like to read an existing FXG file into flash builder and then datamine the file for elements, and add event handlers to those elements.
    For instance, if I have two rectangles in an FXG file (not in the flash builder mxml) and then read it in, I'd like to search for every rectangle and add an event handler that detects a mouse click. If the FXG code changes to three rectangles, I don't want to change my mxml for flash builder.
    Is this possible?

    I'm seeing a pretty tragic death using the following, where theDiagram.fxg is in the assets directory. Does <Graphic> map to a SpriteVisualElement, or is the <Graphic> composed of SpriteVisualElements?
    import assets.theDiagram;
    private var fxgCls:Class = theDiagram as Class;
    private var fxgElement:SpriteVisualElement = new fxgCls() as SpriteVisualElement;
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::updateCallbacks()[E:\dev\4.x\frameworks\projec ts\framework\src\mx\core\UIComponent.as:7093]
    at mx.core::UIComponent/set nestLevel()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:3986]
    at spark.core::SpriteVisualElement/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.x\frameworks\projects\s park\src\spark\core\SpriteVisualElement.as:2106]
    at spark.core::SpriteVisualElement/addChild()[E:\dev\4.x\frameworks\projects\spark\src\spark \core\SpriteVisualElement.as:2070]
    at assets::theDiagram_Text_16710627/createText()
    at assets::theDiagram_Text_16710627()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at mx.core::FlexSprite()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\FlexSprite.as: 61]
    at spark.core::SpriteVisualElement()[E:\dev\4.x\frameworks\projects\spark\src\spark\core\Spr iteVisualElement.as:87]
    at assets::theDiagram()[assets/theDiagram-generated.as:10]
    at SpecViewer()[SpecViewer.mxml:22]
    at _SpecViewer_mx_managers_SystemManager/create()
    at mx.managers.systemClasses::ChildManager/initializeTopLevelWindow()[E:\dev\4.x\frameworks\ projects\framework\src\mx\managers\systemClasses\ChildManager.as:304]
    at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\4.x\frameworks\projects\fram ework\src\mx\managers\SystemManager.as:2810]
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()[E:\dev\4.x\frameworks\projects\frame work\src\mx\managers\SystemManager.as:2637]
    at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()[E:\dev\4.x\framewo rks\projects\framework\src\mx\managers\SystemManager.as:2539]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/timerHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\p reloaders\Preloader.as:515]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

  • Do I need to worry about these event handlers in a grid from a memory leak perspective?

    I'm pretty new to Flex and coudn't figure out how to add event handlers to inline item renderer components from the containing file script so I attached the listnerers simply as part of the components themselves (eg <mx:Checkbox ... chnage="outerDocument.doSomething(event)"../>):
    <mx:DataGrid id="targetsGrid" width="100%" height="100%" doubleClickEnabled="true" styleName="itemCell"
          headerStyleName="headerRow" dataProvider="{targets}"
          rowHeight="19" fontSize="11" paddingBottom="0" paddingTop="1">
         <mx:columns>
         <mx:DataGridColumn width="78" dataField="@isSelected" headerText="">
         <mx:itemRenderer>
              <mx:Component>
                   <mx:HBox width="100%" height="100%" horizontalAlign="center">
                        <mx:CheckBox id="targetCheckBox" selected="{data.@isSelected == 'true'}"
                             change="outerDocument.checkChangeHandler(event);"/>
                        <mx:Image horizontalAlign="center" toolTip="Delete" source="@Embed('/assets/icons/delete.png')" useHandCursor="true" buttonMode="true"
                             click="outerDocument.deleteHandler(event);"/>
                        <mx:Image id="editButton" horizontalAlign="center" toolTip="Edit" source="@Embed('/assets/icons/edit-icon.png')" useHandCursor="true" buttonMode="true"
                             click="outerDocument.editHandler(event);"/>
                   </mx:HBox>
              </mx:Component>
         </mx:itemRenderer>
         </mx:DataGridColumn>
              <mx:DataGridColumn id="Name" dataField="@collectionDesc" headerText="Name" itemRenderer="com.foobar.integrated.media.ui.component.CellStyleForTargetName"/>
              <mx:DataGridColumn id="Created" width="140" dataField="@createDateTime" headerText="Created"  labelFunction="UiHelper.gridDateFormat" />
         </mx:columns>
    </mx:DataGrid>
    This grid is part of a view that will get destroyed and recreated potentially many times during a user's session within the application (there's a large dynamic nature to the app and views are created at run-time.) By destroyed I mean that the view that holds the above datagrid will no longer be referenced under certain circumstances and an entire new view object is created (meaning the old datagrid is no longer refernced and a new one is created.)
    I heard you should clean up event handlers when they are no longer used, and I know at what point the view is destroyed, but I don't know how to clean up the event handlers added to the item renderer components? Is it something that the Flex garbage collector will handle efficiently?
    Also, on a somewhat related note, how could I push the item renderer to an external component since in my event handlers for the item renderer buttons I need a reference to the datagrid.selectedIndex which, as an external item renderer I wouldn't have access to this containing grid?

    No. You don't need explicit cleanup in this case: if your outerDocument is going away, you have nothing to worry about. The event handler leak can happen in sort of the reverse situation: suppose you have a long-lived MyView that contains a custom DataGrid like the one below. Now suppose that MyView frequently destroys and re-creates the grid. And suppose that on its creationComplete event, the grid registers a listener for outerDocument's (MyView's) enterFrame Event. Unless you explicitly remove this listener, MyView will still have a reference to it even after the grid that registered the listener is destroyed (and garbage collected).
    This is a pretty contrived example, but it sort of illustrates the potential for leaks: a certain component is elligible for garbage collection, but some longer-lived component holds a reference to it (or part of it, such as a listener function). If the longer-lived component is elligible for GC as well, you don't really need to worry about proper cleanup. That's what you're paying the GC processor cycles for.

  • Problems with .chart-plot-background and event handlers

    Hello. I'm trying to add event handlers to my chart so that the user can be allowed click within the chart itself to perform certain actions like dragging, zooming, etc. To avoid having to deal with handling mouse clicks that lie outside the chart itself (for example on the axes), I've found that:
    .chart-plot-background
    is the Region that gives me the entire chart and nothing else. However, when I attach mouse listeners to this Region, the event is only registered on half of the cells in the chart. If you've seen the default JavaFX Chart background layout, you know that it contains alternating rows of cells with slightly different coloring. I've found that only the rows with the lightest gray coloring actually register a mouse click on them, which makes me believe the dark grey cells are not part of the .chart-plot-background, but something else on top.
    To me, this feels like an oversight in how the regions of the chart are defined. Why can I not get a listener to work on the whole chart and nothing else? Currently the only workaround seems to be to take the Region:
    .chart-content
    instead, and compute the difference between this region and the .chart-plot-background in order to manually suppress mouse clicks that lie outside .chart-plot-background.
    Anyone have suggestions? Is this worth issuing on the JavaFX Jira?

    Hello,
    I'm not an expert on controls, but here is my guess based on your description: when you register an event handler on a "background" node, it is called only when the mouse hovers over the background node - I suppose the light gray is the background with the light gray cells being transparent and dark grey cells being filled. So the behavior seems correct - you can't expect the events to be delivered to background when it is covered by other nodes. I think you really should register the handler on the entire chart and filter out the events you don't want to handle. This however should not require much of computing the difference between the regions, it should be possible to do just something like
    if (!background.contains(event.getX(), event.getY())) {
        return;
    Provided that the background doesn't reach under the axes as well. Note that if there are any different transforms between the background and the node with the handler registered on it, you may need to recompute the coordinates by
    background.sceneToLocal(event.getSceneX(), event.getSceneY());
    And use the contains method on that.

  • Multiple event handlers for one button

    I'm trying to create a button with 2 event handlers, such
    that when you roll-over the button, a submenu pops up, and when you
    click the button, you go to a certain frame. I feel like this
    shouldn't be hard at all, but it's not working. Below is the
    actionscript I have tried. Both event handlers work as I want them
    to if alone, but the on(release) functionality does not work when I
    try to put them together.(I have Flash 8). Thanks for your help!
    on (release) {
    _root.gotoAndStop("one1");
    tellTarget (_root.navigation) {
    gotoAndStop (1);
    on (rollOver) {
    this.gotoAndPlay("links");
    tellTarget (_root.navigation.introduction) {
    gotoAndStop (1);
    tellTarget (_root.navigation.overview) {
    gotoAndStop (16);
    tellTarget (_root.navigation.coronary) {
    gotoAndStop (1);

    this code is ok, it seems that when u rollover on the button,
    the event is fired and it keeps on running the time u r on it. i
    think just add
    delete this.onRollOver inside rollOver event.

  • 10g: Data Binding in event handlers?

    I'm trying to use data binding in my event handlers so that I can have a definitive source for the Strings that name things like this. I can see that the page is getting generated with the proper names on the elements in the page, but I always get an UnhandledEventException when I trigger the event. The idea is something like this:
            <submitButton text="Refresh" event="${ pageBean.controlRefreshEventName }" >
            </submitButton>
            <submitButton text="Hide Controls" event="${ pageBean.controlHideEventName }" >
            </submitButton>
        <handlers>
            <event name="${ pageBean.controlRefreshEventName }">
                <method class="com.avega.portlets.view.EventHandler"
                        method="handleControlFormSubmit"/>
            </event>
            <event name="${ pageBean.controlHideEventName }">
                <method class="com.avega.portlets.view.EventHandler"
                        method="handleControlFormSubmit"/>
            </event>
        </handlers>
    ...Now in my EventHandler I would be able to use the getXXXName methods when checking for which submit button was hit. Except I'm getting an exception instead.
    (BTW, I only have the two event tags because I wasn't sure how to concatenate the el expressions with a space...)

    No, there's no indication that anything is wrong until I cause the event and get the UnhandledEventException.
    However, I did the an experiment with the following tags, the first in a plain JSP, the second in a UIX page, and it seems that this is the normal way of handling a non-existant bean reference. Both cases printed 'text' in the page and did not complain that 'noBean' didn't exist. It seems you get an error when you reference a non-existant property on an existing bean, but no error if the bean itself doesn't exist. Anyway, UIX doesn't appear to be any different from JSP in this regard.
    <c:out value="${ noBean.noProperty } text" />
    <styledText text="${ noBean.noProperty } text" />

  • Multiple menu items != multiple event handlers?

    I'm developing a program whereby a user can rate how much they like certain images when displayed on screen. The bulk of the work is done, but my rating mechanism (first attempt at one) is currently a right-click pop-up menu with the values 1-10 in ten menu items - naff I know, but its early design stages ;)
    This brings obvious problems, and I don't want to have to code event handlers for each and every Menu item just to set the same parameter to a different value depending on which menu item the user clicked (i.e. I don't want to have to create an event for the first menu item that simply sets and int variable to 1, and do the same for #2 through 10). What I was wondering was, is there any simpler way of implementing this? I.e. can I use the same event for the whole popup menu and detect the value of the option clicked and set the value accordingly? This would also mean, should I need to extend the rating scale above ten, say perhaps to twenty, then there would be no further coding necessary (which is nice! Lol!).
    Can anyone offer any suggestions? I did search, but tbh didn't have a clue what to search for. Your advice is appreciated.

    Implement the ActionListner that allows the constructor to take an argument as to the rating of the menu item, and then set the required rating variable to this when called. For example
    class MyRatingSystem
        int rating = 0;
        public void createMenus()
            JMenu ratings = new JMenu("Ratings");
            for(int i = 0; i < 10; i++)
                JMenuItem rating = new JMenuItem("Vote: " + i);
                rating.addActionListener(new RatingListener(i));
                ratings.add(rating);
        class RatingListener imlpements ActionListener{
            final int rate;
            public RatingListener(int rate)
                this.rate = rate;
            public void actionPerformed(ActionEvent ae)
                rating = this.rate;
    }The above code is inefficient and is only there to serve the purpose of an example(look at the loop, although I would think the compiler could do some loop unrolling?)
    HTH

  • Ensure event handlers are unhooked - Visual webpart

    Hi ,
    I have a visual webpart which has buttons and Images.
    On click of these images and button an event handler is initiated to execute some function.
    Now how and where should i dispose these event handlers.
    I want the event handler to be hooked untill the user is viewing that webpart in that page.Once the user closes or moves to another page i want to unhook the event.
    Where should i use the logic of unhooking event.
    I have User control class which is loded in the webpart class.
    Thanks in Advance.
    Pallavi

    Hi,
    Once a Visual Web Part is inserted into a page, we will be able to use it after the page loaded, the buttons or other controls can be clicked at that time.
    When we close the page, the Visual Web Part will also be gone, the controls in it will also be inaccessible, then the functions written in the click event of these controls will
    also can be executed.
    If this is not you really mean, more details about your requirement would be welcome.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • ALV Grid event handlers

    Hello Friends;
    I have a problem with event handlers. I have defined events for double_click, data_change and hotspot_click. At first run of the program everything runs fine but when I make a change at the screen (like pressing Enter or entering a value at a screen field) the handlers seem to be called a couple of times. For example at a hotspot click I call an accounting document display and when I want to return with back button the program seems to be stuck at document display. Actually it calls event handler over and over again. How can I solve this problem? Can refreshing grid be a solution?
    Thx in advance
    Ali

    Hello Ali
    The problem is that after handling the hotspot event the current cell is still on the field with the hotspot. Thus, when you push ENTER the ALV grid checks the current cell which has a hotspot defined which, in turn, raises event HOTSPOT_CLICK.
    Therefore, you have to move the current cell to another cell that has no hotspot defined. Have a look at the implementation of the event handler method. The hotspot is on field KUNNR. After calling transaction XD03 I shift the current cell to field BUKRS.
    If you comment these lines you will see the same behaviour of the report as you described.
    *& Report  ZUS_SDN_TWO_ALV_GRIDS
    REPORT  ZUS_SDN_ALVGRID_EVENTS.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '1000'  OBLIGATORY.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1,
          ls_col_id   type lvc_s_col.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    *   Set active cell to field BUKRS otherwise the focus is still on
    *   field KUNNR which will always raise event HOTSPOT_CLICK
        ls_col_id-fieldname = 'BUKRS'.
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
            IS_ROW_ID    = e_row_id
            IS_COLUMN_ID = ls_col_id.
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_docking
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = gt_knb1
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'KUNNR'.
      IF ( syst-subrc = 0 ).
        ls_fcat-hotspot = abap_true.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    Regards
      Uwe

  • Document Event Handlers

    How do I access the Page/Open and Doc/Open event handlers using the Javascript debugger ?
    Currently, I can see only a few related to the Closing and Saving of the document...Document Will Save, Document Will Close, etc.
    There is no "Add" button in the Document Actions dialog box that appears when one clicks on Other Tasks when editing a form-based document.
    Also, I noticed there is a Javascript function "SetPageAction" which can be used for the Open event handler, but apparently this must be established via script...
    no GUI counterpart appears to be available.

    There isn't an explicit document open event. Code that you place in a document-level JavaScript will execute when the document is opened.
    To get to the Page Open/Close events, open the Pages navigation pane, select the page you want, right-click > Page Properties > Actions

  • Event Handlers for Dynamic Buttons

    Hi, I hope someone can help. I just can't figure out how to
    solve this problem:
    I am creating an number of buttons dynamically that
    correspond each to a filename read from a directory. The problem is
    I don't know ahead of time how many buttons (files) I will have so
    I create them dynamically in action script. -- this much I can do.
    What I can't figure out is how do I assign each of these
    dynamically created buttons individually specific event handlers?
    ie. I need to know which file icon you clicked on and then take
    action based on that info.
    for example: "folder" is a button icon I have linked from my
    library - i name each instance "folder"+i -- what I need to do is
    do something for folder1, folder2 etc.
    for (i=1;i<numdirs;i++) {
    graphics.attachMovie("folder","folder"+i,depth);
    graphics["folder"+i]._y= coordy2;
    // want to put an event handler here for each
    graphics["folder"+i] button
    I wanted to do something like:
    graphics["folder"+i].onRelease = function() {
    test_txt.text = i;
    but each button I click on gives me i= numdirs (ie the max
    number -- for example 6 if there are 6 files, I can't identify
    which button you actually clicked on -- button1 through 6 all
    deliver the number 6 to test_txt.text)
    I hope that makes sense - if someone can take a swag at this
    and point me in the right direction I will be very appreciative.
    Best Regards,
    Tom

    There is other way to do that.. whenever you call a
    attachMovie or loadMovie
    function there is a return value that corresponds to the
    actual movieclip
    created on the flash movie. ie
    for (i=1;i<numdirs;i++) {
    var temp_mc:MovieClip =
    graphics.attachMovie("folder","folder"+i,depth);
    that new reference temp_mc is the newly created movieclip and
    you can do
    whatever you want with it, ie:
    for (i=1;i<numdirs;i++) {
    var temp_mc:MovieClip =
    graphics.attachMovie("folder","folder"+i,depth);
    temp_mc._y = 30
    temp_mc.id = I
    //even assign new funtions to events
    temp_mc.onRelease = releaseFunction
    function releaseFunction(){
    trace("do something on the release event")
    <DIV>&quot;charmcityMD&quot;
    &lt;[email protected]&gt; wrote in
    message
    news:ed2l97$n8$[email protected]..</DIV>> THANK YOU
    soo
    much -- I have been pondering this and scanning the web for
    hours. Your
    solution is perfect. I very very much appreciate your help.
    >
    > Best Regards,
    > Tom

  • Event Handlers not Working

    Hi. I'm trying to get my .fla to go to my 3 movie instances but when the startPage appears, the buttons don't click to the movie instances. I've check the names and these are correct. Can you spot anything in the code? Thanks
    package  {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    public class Main extends MovieClip
      var startPage:StartPage;
      var hillPage:HillPage;
      var pondPage:PondPage;
      public function Main()
       startPage = new StartPage;
       hillPage = new HillPage;
       pondPage = new PondPage;
       addChild(startPage);
       // Add event listeners
       startPage.hillButton.addEventListener(MouseEvent.CLICK,onHillButtonClick);
       startPage.pondButton.addEventListener(MouseEvent.CLICK,onPondButtonClick);
       hillPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Hill);
       pondPage.backToStartButton.addEventListener(MouseEvent.CLICK,onBackButtonClick_Pond);
      //Event handlers
      function onHillButtonClick(event:MouseEvent):void
      addChild(hillPage);
      removeChild(startPage);
    function onPondButtonClick(event:MouseEvent):void
      addChild(pondPage);
      removeChild(startPage);
    function onBackButtonClick_Hill(event:MouseEvent):void
      addChild(startPage);
      removeChild(hillPage);
      function onBackButtonClick_Pond(event:MouseEvent):void
      addChild(startPage);
      removeChild(pondPage);

    are there any error messages?
    if not, use the trace function to debug.  eg, place trace functions in your event handlers to see if those functions are being called.

  • Event handlers for backbutton

    Hi,
    I want perform some validations when I press back button.how to find event handlers for back button,because F2
    is not giving full info for back button.
    Regards,
    Brahmaji

    Hi,
    the back button is always part of toolbar buttons.
    So you can open the view controller class and open the GET_TOOLBAR_BUTTONS method from that class.
    In this method you see how the BACK button is defined. One of the attribute of button structure is ON_CLICK.
    The value of this attribute should be the event name that is triggered when the button is clicked.
    Now open the DO_HANDLE_EVENT method from the view controller class, you will have methods with prefix EH_ON
    after the prefix you see the event name. If you find one that mached to the event name of the BACK button, then this is the event handler that is triggered by the BACK button.
    Regards,
    Steve

Maybe you are looking for