Writing a function to that sorts any object

I am trying to write a function that sorts any type of array of objects. For example, I want to call
NewArray = exampleclass.sort(ObjectOfAnyType).
The sort function has to return a new array. I have run into two errors, however.
Error #1
as3.java [21:1] cannot resolve symbol
symbol : variable Object
location: class as3
if (Object instanceof Comparable)
^
Error #2
as3.java [25:1] incompatible types
found : java.lang.Object
required: java.lang.Object[]
Object [] rtn = obj.clone();
*** Below is my source code ***
import java.*;
public class as3 {
/** Creates new as3 */
public static Object sort(Object [] obj)
     if (Object instanceof Comparable)
     if (Object instanceof Cloneable)
     Object [] rtn = obj.clone();
for (int i = 0; i<obj.length-1; i++)
for (int j=i+1; j<obj.length; j++)
if (rtn.compareTo(rtn[j]) == 1)
Object [] tmp = rtn[i];
rtn[i] = obj[j];
rtn[j] = tmp;
else
throw new ObjectIsNotComparableException("Object not comparable");
Any help appreciated. Thanks!

Changing from "Object" to the name "obj" fixed the
statement:
if (obj instanceof Cloneable) but not if (obj
instanceof Comparable).
I don't know what's causing this one yet... worry about that in a sec
I am also getting one new error now:
as3.java [28:1] cannot resolve symbol
symbol : method compareTo (java.lang.Object)
location: class java.lang.Object
if (rtn[ i].compareTo(rtn[j])
This one is because rtn[ i] (and rtn[j]) is an Object, which has no method compareTo. Try casting it to a Comparable...
I think I just worked out why it let you go with the cloneable, but not with the comparable. obj is an array, and sure an array is cloneable, but how could you compare an array? Sure you can compare the elements in the array... So either check if obj[0] instanceof Comparable, or drop the test all together.
Note: checking obj[0] will give you an exception if someone asks you to sort an array of 0 length (no elements)
Hope this helps,
Radish21

Similar Messages

  • Copying any object

    I know if I try to assign an object reference to other, a new object won't be created, only a copy of that reference. For example:
    String s1, s2;
    s1 = new String ("My new String");
    s2 = s1;But and if I want to copy (clone) an object (all the data inside it)? Is there a method that does it for any object, like a Copy ()?
    Note: Of course I know if I want a copy of an array of integers, for example, I can do a counter-controlled iteration to get the clone. But I want the method that copies any object.

    No, there is no method that clones every object. The clone() method that is specified by the Object class must be implemented for any class that wishes to support cloning.
    Since you cannot tell the semantics of a class externally (only the properties, methods and inner declarations) there is no fool-proof way of copying instances externally.

  • Is there a Tool or function (in Illustrator or InDesign) that selects any shape and "punches" a "hole" of that shape all the way down through multiple objects to the paper or artboard?

    Is there a Tool or function (in Illustrator or InDesign) that selects any shape and “punches” a “hole” of that shape all the way down through multiple objects to the paper or artboard?

    In Illustrator, group the objects that you want to punch through, and use the transparency pallet.

  • Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    List and table controls -> listbox..is that what you are thinking of?
    The listbox presents the user with a list of options, and you can set it to only accept one selection at a time...Adding new data to the list can not be done directly by the user but if you make e.g. a text control and a button you can programatically insert new objects described in the text box when the button is pressed...(see example).
    If you need more than one column you have the multicolumn listbox. If you want the users to write new entries directly yu can use a table and read selected cells using it's selection start property to read what cell has been selected.
    MTO
    Attachments:
    Listbox_example.vi ‏34 KB

  • Is it possible to hide the yellow box that appears when you scroll over any object in the form?

    Is it possible to hide the yellow box that appears when you scroll over any object in the form? This box contains the item name or caption.

    Hi,
    Under Tools ... Options ... Workspace, there is an option "Display Object Name Tool Tips While Pointing".
    Try clearing that.
    Bruce

  • Is there any function module that brings out profile planner

    Hello experts,
    Is there any function module that brings out profile planner (I want to set planner profile as u201CSAP800u201D. I am using 7KE1 transaction.
    Example: I know, the FM - K_KOKRS_SET_BATCHINPUT will set the controlling area to 'CTIC' for the entire batch input process.
    Thanks in advance.

    look at these fms..
    CACS_PROFILE_PARTNER_READ
    CACS_PROFILE_SHOW

  • I am trying to use automator to open a safari popup window that will automatically log me into whatever account and I attempted to type up an applescript that utilized the "System Events" function with no avail, any ideas?

    I am trying to use automator to open a safari popup window that will automatically log me into whatever account and I attempted to type up an applescript that utilized the "System Events" function with no avail, any ideas?

    Hi
    In iMovie'11 (version 9.0.x)
    on top menu row - Apple/iMovie/File/Edit/Cut (Can vary dep. on language - in Swedish Apple/iMovie/Arkiv/Redigera/Klipp . . . )
    down Cut menu - Slow playback/Raspid Playback/Re-play in Slow Motion and onvards
    Here one can select the Pre-Set speeds
    Are you familiar with getting 'inspector' to run?
    No - but I guess that Double Click on clip/sequense or ctrl-Click on it might open it.
    Yours Bengt W

  • Is there any function module that generates date of 30th september of next

    is there any function module that generates date of 30th september of next year.?

    May be u mean...20100930
    You can simply
    Add 10000 to this years sept 30...If you want sept 30 from today...
    Data: G_DATE Type Sy-DATUM.
    G_DATE = Sy-DATUM.
    G_DATE+4(02) = '09'.
    G_DATE+6(02) = '30'.
    G_DATE0(04) = G_DATE0(04) + 1.
    Santhosh

  • I need a spreadsheet that  allow any advanced functionality such as macros and active x components. Any possibility of that ever happenning?

    I have spreadsheets that contain macros. Unless and until software producers change the programming or capability that allow any advanced functionality such as macros and active x components, I cannot use my ipad. So I am forced to lug my laptop and my ipad around when the ipad would be perfect for my work in insurance. The fact that this capability does not exsist in docs to go or numbers means there either is a major hang up or these software manufacturers don't feel the need is strong enough. Either way, it really puts people like me in a bind. Does anyone have a solution for this? Is it really that hard of a thing to do to be able to read and run macros?

    Unfortunately there is NONE. I have tried searching for a long time but never succeeded to find an app that can read Macros. I hope there must be a very strong limitation for developers to support macros.

  • Hotspot-clicking (Insert function) plus ALV Sorting

    Hi,
    I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
    However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected. 
    Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
    Will appreciate any help on this.
    Thanks!
    Michael

    Hello Michael
    Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
    Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
    Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
    When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
    *& Report  ZUS_SDN_ALVGRID_HOTSPOT_SORT
    *& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
    REPORT  zus_sdn_alvgrid_hotspot_sort.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE vbap.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syrepid,
      gt_sort          TYPE lvc_t_sort,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_sel_row    TYPE lvc_s_row. " selected row
        CLASS-METHODS:
          handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
            IMPORTING
              er_data_changed
              e_onf4
              e_onf4_before
              e_onf4_after
              sender,
          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_data_changed.
        FIELD-SYMBOLS: <lt_outtab>  TYPE ty_t_outtab.
        BREAK-POINT.
      ENDMETHOD.                    "handle_data_changed
      METHOD handle_hotspot_click.
        " define local data
        DATA: ls_outtab    TYPE ty_s_outtab,
              ld_msg        TYPE bapi_msg.
        BREAK-POINT.
        CLEAR: lcl_eventhandler=>ms_sel_row.
        ms_sel_row = e_row_id.
        READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
        CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
                                              ls_outtab-posnr
          INTO ld_msg.
          message i398(00) with ld_msg.
        " Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'INSERT'
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_vkorg      TYPE vkorg  DEFAULT '0001'  OBLIGATORY.
    START-OF-SELECTION.
    **  SELECT  * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
    **    UP TO 200 ROWS
    **         WHERE  vkorg = p_vkorg.
      SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
        UP TO 100 ROWS.
      PERFORM init_controls.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
      PERFORM set_sorting.
      " Register EDIT event
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          error      = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed  FOR go_grid,
        lcl_eventhandler=>handle_hotspot_click FOR go_grid.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 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'.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = abap_true
          is_variant                    = gs_variant
          i_save                        = 'A'
    *      i_default                     = 'X'
          is_layout                     = gs_layout
    *      is_print                      =
    *      it_special_groups             =
    *      it_toolbar_excluding          =
    *      it_hyperlink                  =
    *      it_alv_graphics               =
    *      it_except_qinfo               =
    *      ir_salv_adapter               =
        CHANGING
          it_outtab                     = gt_outtab
          it_fieldcatalog               = gt_fcat
          it_sort                       = gt_sort
    *      it_filter                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  CALL METHOD go_grid->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **    EXCEPTIONS
    **      finished       = 1
    **      OTHERS         = 2.
    **  IF sy-subrc ne 0.
    ***       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    ***                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    **  ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT'.
          PERFORM insert_row.
        WHEN OTHERS.
          " Check for changed data at the frontend (= grid control)
          CALL METHOD go_grid->check_changed_data( ).
      ENDCASE.
      CALL METHOD go_grid->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          others = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc NE 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_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          others   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog.
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'VBAP'  " 'VBAK'
    *     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 NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  LOOP AT gt_fcat INTO ls_fcat.
    **    CASE ls_fcat-fieldname.
    **      WHEN 'VBELN'  OR
    **           'ERDAT'  OR
    **           'ERZET'  OR
    **           'ERNAM'  OR
    **           'AUART'  OR
    **           'NETWR'  OR
    **           'WAERK'.
    **        CONTINUE.
    **      WHEN OTHERS.
    **        ls_fcat-no_out = abap_true.
    **    ENDCASE.
    **    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
    **  ENDLOOP.
    * Only non-key fields are editable
    **  ls_fcat-edit = 'X'.
    **  MODIFY gt_fcat FROM ls_fcat
    **    TRANSPORTING edit
    **    WHERE ( fieldname NE space ).
      ls_fcat-hotspot = abap_true.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING hotspot
        WHERE ( fieldname = 'AUART'   OR
                fieldname = 'VBELN' ).
    **  DELETE gt_fcat FROM 15 TO 99.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  SET_SORTING
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_sorting .
    * define local data
      DATA: ls_sort   TYPE lvc_s_sort.
      REFRESH: gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'POSNR'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
    ENDFORM.                    " SET_SORTING
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM insert_row .
    * define local data
      DATA: ls_outtab   TYPE ty_s_outtab,
            ld_order    TYPE vbeln.
      READ TABLE gt_outtab INTO ls_outtab
                           INDEX lcl_eventhandler=>ms_sel_row-index.
      ld_order = ls_outtab-vbeln.
      " Find last item of sales order
      LOOP AT gt_outtab INTO ls_outtab
                        WHERE ( vbeln = ld_order ).
      ENDLOOP.
      " Create next item:
      add 10 to ls_outtab-posnr.
      " NOTE: added at the end of the list
      APPEND ls_outtab TO gt_outtab.
      " NOTE: insert new row AFTER selected row => works, too
    **  INSERT ls_outtab INTO gt_outtab
    **                   INDEX lcl_eventhandler=>ms_sel_row-index.
    ENDFORM.                    " INSERT_ROW

  • Function Module that will retrieve the Field Catalogs of a Display Variant

    Hello Experts,
    Are there any function modules that I can use to retrieve the field catalogs (fields to be displayed in ALV report) by passing the display variant name?
    An RFC needs to apply this to determine which field(data) to be passed to XI (calling system) depending on user login.
    Thanks in advance!

    These are the various FM available for Variants (field Layout)
    REUSE_ALV_VARIANT_ALL_MAINTAIN Maintain all display variants for one object
    REUSE_ALV_VARIANT_DEFAULT_GET  Read default display variant (description only, w/o field catalog)
    REUSE_ALV_VARIANT_EXISTENCE    Checks whether a display variant exists
    REUSE_ALV_VARIANT_F4           Display variant selection dialog box
    REUSE_ALV_VARIANT_MAINTAIN     Definition of a display variant outside the list context
    REUSE_ALV_VARIANT_SAVE         Save a display variant
    REUSE_ALV_VARIANT_SELECT       Read a display variant
    Regards,
    Amit

  • To track who changed any object

    Hi all
    Is there any Function module to track the user id of the user who has made a change in any object ..say a sales order or purchase order. I am doing using table cdhdr, but this takes a long time as data is huge.
    Is there any way out.
    Regards
    Dinesh

    Hi,
    check BAPI_USER_GET_DETAIL
    You can use FM "BAPI_USER_GET_DETAIL"
    In that Export Parameters ADDRESS->E_MAIL for email of the user.
    Check this FM.
    CNV_GET_USER_ROLE
    SO_CHECK_USER_ROLE
    try this..
    RSRA_USERS_OF_AGR_GET
    Regards,
    Shiva Kumar

  • To prevent user from droping any object from a sepacific schema

    Dear User
    I have a database user like "aaa" in oracle 7.3.4.0.1 database.i do not want user "aaa" to drop his own schema objects like table and any other objects that he is owner.Do i have any system privilege to stop this user from doing so.User should be able to create objects and modify object but not to drop any object.For this purpose i have created a database trigger at database level to stop user "aaa" for doing above action.this trigger is giving me error on creation in oracle 7.3.4.0.1 .But when i tried same trigger in oracle 8i and 9i it work well.In oracle 8i and 9i it is preventing user from droping his own objects but i get other errors also along with raised error in trigger which i want to stop .The error which i am raising in trigger is
    ORA-20001 INVALID COMMAND BUT OTHER TWO ERRORS THAT R RAISED AUTOMATICALLY ARE
    ORA-00604 ERROR OCCURED AT RECURSIVE SQL LEVEL 1
    AND
    ORA-06512 AT LINE 8
    I WANT TO STOP THESE TWO ERRORS .
    PLZ HELP ME IN THIS REGARD AS SOON AS POSSBILE .
    Thank u.

    Given that you have not posted your code it is very difficult to know why you are getting these errors.
    Howver, I can take a guess. If I were trying to implement this functionality I would build a database event trigger that fired whenever a DROP command was issued and cause that command to fail. If this is the approach you've taken I think you are out of luck, as I belive DDL triggers were introduced in Oracle 8.
    Mind you, it's been a long time since I worked on Oracle7, so I might be wrong. In which case post your code, don't make me guess again.
    Cheers, APC

  • EventListener function specific to generated display object container

    This has to be simple, if only I knew how. I'm an AS3 newbie,
    and am having difficulty setting up multiple specific
    EventListeners within a code generated display object container.
    I am generating a 'page' (Sprite) with a heap of 'cards'
    (Sprites) on it. Each of those cards, in turn, contains a selection
    of text boxes and other objects generated from database output
    using a 'for' loop.
    My hope is to attach an EventListener to each 'card' so that
    a MouseEvent will let me manipulate the data that lead to the
    content of that actual card (the i-th iteration of my for loop).
    I've been playing with everything I can think of (limited
    repertoire of thoughts though) and the best I've managed is for my
    EventListener to access the final set of data, whichever 'card' I
    click on.
    I've summarised and attached my code for the function, and
    would appreciate any advice (however basic) on how to get back to
    the i-set of data from the EventListener attached to the i-th card.
    I can handle the PHP and MySQL side of things but am fumbling my
    way into the OOP of AS3.
    Cheers
    Dougal

    Another way would be to extend Sprite and add an id value.
    Something like:
    package{
    import flash.display.Sprite;
    public class MySprite extends Sprite {
    private var _id:int;
    public function MySprite(id:int){ _id = id; }
    public function get id():int { return _id; }
    And then in your code you'd just make instance of MySprite,
    passing it i:
    // build the cards and text boxes and add them to the
    reviewPage
    for (var i:int = 1; i < (cardsRequired+1); i++) {
    // setup the locations for all the objects
    var displayCard:Sprite = new MySprite(i);
    You can then get i in the event listener function by using
    the id getter:
    function accessThisData(e:MouseEvent):void{
    trace(e.target.parent.id);
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Function module to read Lock objects

    Hi all,
    I'm doing a generic search program for all the objects..
    Is there any function module to read Lock objects....
    that is to know wat r all the tables and Lock parameters are there in a lock object

    Hi Gayathri
    Please read the table DD25L with AGGTYPE = 'E' to get all the lock object names in the field VIEWNAME. Use these lock object to read the table DD27S to get the fields present in these lock objects.
    Hope this helps !
    Regards
    Ranganath
    PS : Reward points for all useful answers !

Maybe you are looking for

  • My Microsoft Word is not opening - error 1712

    my Microsoft Word is not opening - error 1712 - Mac OSX version 10.6.8 - processor 2GHz Intel Core 2 Duo - Memory 2 GB667 MHzDDR2 SDRAM my memory is been nearly used up, I have withdrawn 2 GB of archives so that I can continue using my machine, as I

  • The creation of the new workspace has been partially successful

    Hi, I tried to create a Workspace called WSMedicina and the following error apears: The creation of the new workspace has been partially successful. Exception Message: Cannot find library item WsMedicina. The error cause: Cannot add Library Service.

  • [Forum FAQ] How to format and combine PowerShell outputs

    Format the output with "Format-Table" and "Format-list" Sometimes when we query Powershell cmdlet, we would get ellipses in the result, which is not desirable. In this scenario, we can use the cmdlet "Format-Table" and "Format-list" to view the entir

  • The "close" option is missing in "File" . It only has exit

    At the top of my firefox screen are the options: File, Edit, View, etc. Withing the "File" I used to have in the drop down menu an item called "close". Now the only option I have to leave a panel is exit. However, I have to restart firefox every time

  • Lead Org determination from Employee responsible

    Hi, We are creating leads by executing campaigns. Now when leads are created, Sales org is determined from user who has logged into the system, however I want to change this. Sales org in lead should be determined by employee responsible. I am not su